我与重绘功能重绘功能无法正常工作..
当我编译出了问题,错误的是
[email protected]:~/Desktop$ javac LoadImageApp.java
LoadImageApp.java:17: cannot find symbol
symbol : method repaint(int,int,int,int,int)
location: class java.awt.Graphics
g.repaint(1000,0,0,1440,900)
^
1 error
,这是我的代码 - >
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;
public class LoadImageApp extends Component {
BufferedImage img;
public void paint(Graphics g) {
g.drawImage(img, 0, 0, null);
super.update(g);
g.repaint(1000,0,0,1440,900);
}
public LoadImageApp() {
try{
img = ImageIO.read(new File("screenshot.jpg"));
}catch(IOException e){}
}
public Dimension getPreferredSize() {
if (img == null) {
return new Dimension(100,100);
} else {
return new Dimension(img.getWidth(null), img.getHeight(null));
}
}
public static void main(String[] args) {
JFrame f = new JFrame("Load Image ");
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
f.add(new LoadImageApp());
f.pack();
f.setVisible(true);
}
}
谁能告诉我什么是问题?我打算做一个程序来显示图像,并保持每0.1秒刷新一次。该图片会从其他机器和每0.1秒接收和图像将保持覆盖旧形象..
在此先感谢那些谁回答。谢谢!!!!!!
的g.repaint(...)i。从下面http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/Component.html#repaint%28long链路参考, %20int,%20int,%20int,%20int%29 和我对graphice和组件怎么我是新来的Java很困惑。 ..呃..如果我想加载图像,显示和刷新,哪一个更适合我使用它?然后提前答复.. – Eric 2012-04-02 06:15:27