代码显示第19行错误第50行错误
也就是Icon icon=new ImageIcon(url); new SwingAndThread();
在23行添加Runable()也报错
package javaex;
import java.awt.;
import java.net.URL;
import java.lang.;
import javax.swing.*;
public class SwingAndThread extends Thread {
private static final int LEFT = 0;
private static Thread t;
private int count;
JFrame jf=new JFrame();
JLabel jl=new JLabel();
Container container=jf.getContentPane();
public SwingAndThread(){
jl.setBounds(300, 200, 200, 100);
container.setLayout(null);
URL url =SwingAndThread.class.getResource("1.gif");
Icon icon=new ImageIcon(url);
jl.setIcon(icon);
jl.setHorizontalAlignment(SwingAndThread.LEFT);
jl.setBounds(10,10,200,50);
jl.setOpaque(true);
t=new Thread(){
public void run(){
while( count<200){
jl.setBounds(count, 10, 200, 50);
try{
Thread.sleep(1000);
}catch(Exception e){
e.printStackTrace();
}
count=count+4;
if(count==200)
count=10;
}
}
};
t.run();
jf.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new SwingAndThread();
}
}