这个JAVA程序为什么不能出现图片?
importjava.awt.*;importjavax.swing.*;importjava.awt.event.*;importjava.util.EventList...
import java.awt.* ;
import javax.swing.* ;
import java.awt.event.*;
import java.util.EventListener;
public class zz extends JFrame{
zzpane pane=new zzpane();
public zz(){
super("按时间动");
JPanel pane=new JPanel();
pane.setLayout(new GridLayout(1,1,15,15));
setVisible(true);
setContentPane(pane);
setSize(344,344);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] a){zz k=new zz();}
}//上面设置面板
class zzpane extends JPanel implements Runnable{
Thread runner;
int x=30;
Image a;
public zzpane(){
Toolkit kit=Toolkit.getDefaultToolkit();
a=kit.getImage("F://java//a.jpg");
if(runner==null){
runner=new Thread(this);
runner.start();
}
}
@Override
public void run(){}
//线程
@Override
protected void paintComponent(Graphics arg0){
Graphics2D comp=(Graphics2D)arg0;
comp.drawImage(a,x,30,this);
}
} 展开
import javax.swing.* ;
import java.awt.event.*;
import java.util.EventListener;
public class zz extends JFrame{
zzpane pane=new zzpane();
public zz(){
super("按时间动");
JPanel pane=new JPanel();
pane.setLayout(new GridLayout(1,1,15,15));
setVisible(true);
setContentPane(pane);
setSize(344,344);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] a){zz k=new zz();}
}//上面设置面板
class zzpane extends JPanel implements Runnable{
Thread runner;
int x=30;
Image a;
public zzpane(){
Toolkit kit=Toolkit.getDefaultToolkit();
a=kit.getImage("F://java//a.jpg");
if(runner==null){
runner=new Thread(this);
runner.start();
}
}
@Override
public void run(){}
//线程
@Override
protected void paintComponent(Graphics arg0){
Graphics2D comp=(Graphics2D)arg0;
comp.drawImage(a,x,30,this);
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询