错误原因在哪 import java.awt.Container;import java.net.URL;import

错误原因在哪

import java.awt.Container;
import java.net.URL;
import javax.swing.*;
public class SwingAndThread extends JFrame {
x05private JLabel jl=new JLabel();
x05private static Thread t;
x05private int count=0;
x05private Container container=getContentPane();
x05
x05
x05public SwingAndThread(){
x05x05setBounds(300,200,250,100);
x05x05container.setLayout(null);
x05x05URL url=SwingAndThread.class.getResource("F:\1.gif");
x05x05Icon icon=new ImageIcon(url);
x05x05jl.setIcon(icon);
x05x05
x05x05
x05x05jl.setHorizontalAlignment(SwingConstants.LEFT);
x05x05jl.setBounds(10,10,200,50);
x05x05jl.setOpaque(true);
x05x05t=new Thread(new Runnable(){
x05x05x05public void run(){
x05x05x05x05while(count<=200){
x05x05x05x05x05jl.setBounds(count,10,200,50);
x05x05x05x05x05try{
x05x05x05x05x05x05Thread.sleep(1000);
x05x05x05x05x05}catch(Exception e){
x05x05x05x05x05x05e.printStackTrace();
x05x05x05x05x05}
x05x05x05x05x05count+=4;
x05x05x05x05x05if(count==200){
x05x05x05x05x05x05count=10;
x05x05x05x05x05}
x05x05x05x05}
x05x05x05x05
x05x05x05}
x05x05});
x05x05t.start();
x05x05container.add(jl);
x05x05setVisible(true);
x05x05setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
x05}
x05public static void main(String[] args)throws Exception {
x05x05new SwingAndThread();


x05}


}
xjcn61 1年前 已收到1个回答 举报

年本法 幼苗

共回答了23个问题采纳率:91.3% 举报

URL url=SwingAndThread.class.getResource("F:\1.gif"); 这句删掉
Icon icon=new ImageIcon("F:\1.gif");在这 直接写路径

1年前

6
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 0.024 s. - webmaster@yulucn.com