📄 runnabledem.java
字号:
import java.awt.*;
import java.awt.event.*;
public class RunnableDem {
public static void main(String[] args) {
Mywindow my=new Mywindow();
my.pack();
}
}
class Mywindow extends Frame implements Runnable{
Button b=new Button("ok");
int x=5;
Thread t=null;
Mywindow(){
setBounds(500,100,120,120);
setLayout(new FlowLayout());
setVisible(true);
add(b);
b.setBackground(Color.green);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
t=new Thread(this);
t.start();
}
public void run(){
while(true){
x=x+1;
if(x>100)
x=5;
b.setBounds(40,40,x,x);
try{
t.sleep(200);
}catch(InterruptedException e){}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -