import javaawtFont;
import javaawteventActionEvent;
import javaawteventActionListener;
import javaxswingJButton;
import javaxswingJFrame;
import javaxswingJLabel;
import javaxswingJPanel;
public class COLO {
static JLabel jl=new JLabel("无");
public static void main(String[] args) {
JFrame jf=new JFrame("");
jfsetDefaultCloseOperation(jfEXIT_ON_CLOSE);
jfsetBounds(400,300,400,400);
JButton jb=new JButton("开始");
jfadd(jb,"South");
JPanel jp=new JPanel();
jpadd(jl);
jlsetFont(new Font("plain",0,200));
jfadd(jp);
jbaddActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
//主要在这段,新建一个线程运行,这样就不会阻塞主线程了
new Thread(){
public void run(){
for(int i=0;i<10;i++){
jlsetText(""+i);
try {
Threadsleep(1000);
} catch (InterruptedException e1) {
e1printStackTrace();
}
}
}
}start();
}});
jfsetVisible(true);
}
}Systemoutprintln("Ai: hello, Mr Li!");
Threadsleep(1000);
Systemoutprintln("Li: hello, Mr Ai!");
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)