当前位置: 技术问答>java相关
简单的程序就是通不过?
来源: 互联网 发布时间:2015-01-02
本文导语: 一直就出这个错,搞不懂。 这是编译的错误提示: tt4.java:68: Identifier expected. Bufg.drawImage(pic,0,0,this); Note: tt4.java uses or overrides a deprecated API. Recompile with "-deprecation " for details. 1 error, 1 warning 源程序如下...
一直就出这个错,搞不懂。
这是编译的错误提示:
tt4.java:68: Identifier expected.
Bufg.drawImage(pic,0,0,this);
Note: tt4.java uses or overrides a deprecated API. Recompile with "-deprecation
" for details.
1 error, 1 warning
源程序如下:
import java.applet.*;
import java.awt.*;
import java.awt.image.*;
public class tt4 extends Applet
{
Image art,Buf;
int onced=0;
boolean is_color=true;
Graphics Bufg;//使用双缓冲区技术抑制闪烁;
Dimension xy=null;
public void init()
{ art=getImage(getDocumentBase(),"test.jpg");
resize(640, 480);//装入图片;
}
public void paint(Graphics g)
{ if (onced==0)
//如果是第一次装入图片,则直接显示;
{ g.drawImage(art,0,0,this);
}
if ((onced==1)||(onced==2)) //如果正在进行灰度变换,则提示等待;
{ g.setColor(new Color(255,200,0));
g.drawString("running!", 1, 30);
}
if (onced==3) //如果灰度变换完毕,则显示结果;
{ if (is_color) g.drawImage(Buf,0,0,this);
else g.drawImage(art,0,0,this);
is_color=!is_color;//在彩色与黑白之间变化;
}
}
public boolean mouseDown(Event evt, int x, int y)
{ if (onced==0)
{ onced=1;
}
repaint();//用鼠标触发事件;
return true;
}
public boolean mouseUp(Event evt, int x, int y)
{ if (onced==1)
{ onced=2;
int wd=art.getWidth(this); //取得图片宽;
int ht=art.getHeight(this);//取得图片高;
GetPixels(art,0,0,wd,ht);//调用灰度变换方法;
}
return true;
}
public void GetPixels(Image img,int x,int y,int w,int h)
{ int[]pixels=newint[w*h];
//定义一块内存空间;
int gray;
PixelGrabber pg=new PixelGrabber(img,x,y,w,h,pixels,0,w);
try{pg.grabPixels();
}
catch(InterruptedExceptione e)
{System.err.println("interrupted waiting for pixels!");
return;
}
for(int j=0;j>(int)((16&0xff)*0.3);)
{
gray+=(int)(((pixels[w*j+i]>>8)&0xff)*0.59);
gray+=(int)(((pixels[w*j+i] )&0xff)*0.11);
//由红,绿,蓝值得到灰度值;
pixels[w*j+i]=(255
这是编译的错误提示:
tt4.java:68: Identifier expected.
Bufg.drawImage(pic,0,0,this);
Note: tt4.java uses or overrides a deprecated API. Recompile with "-deprecation
" for details.
1 error, 1 warning
源程序如下:
import java.applet.*;
import java.awt.*;
import java.awt.image.*;
public class tt4 extends Applet
{
Image art,Buf;
int onced=0;
boolean is_color=true;
Graphics Bufg;//使用双缓冲区技术抑制闪烁;
Dimension xy=null;
public void init()
{ art=getImage(getDocumentBase(),"test.jpg");
resize(640, 480);//装入图片;
}
public void paint(Graphics g)
{ if (onced==0)
//如果是第一次装入图片,则直接显示;
{ g.drawImage(art,0,0,this);
}
if ((onced==1)||(onced==2)) //如果正在进行灰度变换,则提示等待;
{ g.setColor(new Color(255,200,0));
g.drawString("running!", 1, 30);
}
if (onced==3) //如果灰度变换完毕,则显示结果;
{ if (is_color) g.drawImage(Buf,0,0,this);
else g.drawImage(art,0,0,this);
is_color=!is_color;//在彩色与黑白之间变化;
}
}
public boolean mouseDown(Event evt, int x, int y)
{ if (onced==0)
{ onced=1;
}
repaint();//用鼠标触发事件;
return true;
}
public boolean mouseUp(Event evt, int x, int y)
{ if (onced==1)
{ onced=2;
int wd=art.getWidth(this); //取得图片宽;
int ht=art.getHeight(this);//取得图片高;
GetPixels(art,0,0,wd,ht);//调用灰度变换方法;
}
return true;
}
public void GetPixels(Image img,int x,int y,int w,int h)
{ int[]pixels=newint[w*h];
//定义一块内存空间;
int gray;
PixelGrabber pg=new PixelGrabber(img,x,y,w,h,pixels,0,w);
try{pg.grabPixels();
}
catch(InterruptedExceptione e)
{System.err.println("interrupted waiting for pixels!");
return;
}
for(int j=0;j>(int)((16&0xff)*0.3);)
{
gray+=(int)(((pixels[w*j+i]>>8)&0xff)*0.59);
gray+=(int)(((pixels[w*j+i] )&0xff)*0.11);
//由红,绿,蓝值得到灰度值;
pixels[w*j+i]=(255