public class PictureMove extends JFrame{
PictureMove(){
this.getContentPane().add(new MyPanel());
setSize(400, 400);
setVisible(true);
}
public static void main(String[] args) {
JFrame.setDefaultLookAndFeelDecorated(true);
new PictureMove();
}
}class MyPanel extends JPanel implements MouseMotionListener, MouseListener { int x = 0, y = 0;
int dx = 0, dy = 0;
BufferedImage bimage1, bimage2;
boolean start = false;
boolean downState = false; public MyPanel() {
this.setBackground(Color.white);
this.addMouseListener(this);
this.addMouseMotionListener(this);
Image image = this.getToolkit().getImage("c:/1.jpg");
if (image.getWidth(this) == -1) {
System.out.println("can not open!");
System.exit(-1);
}
....
}
异常是:
Exception in thread "main" java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be <= 0我的程序进行到这里就跳出来了,后面的都没运行,等着高手指点迷津。
PictureMove(){
this.getContentPane().add(new MyPanel());
setSize(400, 400);
setVisible(true);
}
public static void main(String[] args) {
JFrame.setDefaultLookAndFeelDecorated(true);
new PictureMove();
}
}class MyPanel extends JPanel implements MouseMotionListener, MouseListener { int x = 0, y = 0;
int dx = 0, dy = 0;
BufferedImage bimage1, bimage2;
boolean start = false;
boolean downState = false; public MyPanel() {
this.setBackground(Color.white);
this.addMouseListener(this);
this.addMouseMotionListener(this);
Image image = this.getToolkit().getImage("c:/1.jpg");
if (image.getWidth(this) == -1) {
System.out.println("can not open!");
System.exit(-1);
}
....
}
异常是:
Exception in thread "main" java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be <= 0我的程序进行到这里就跳出来了,后面的都没运行,等着高手指点迷津。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货