问答题
本题程序的功能是:主窗口中有一个按钮,按钮的长和宽每200ms增加1,当达到100时又恢复原来大小重新进行增加。请将下述程序补充完整(注意:不得改动程序的结构,不得增行或删行)。
import java.awt.*;
import java.awt.event.*;
public class simple
{
public static void main (String args[])
{
Mywin win = new Mywin();
}
}
class Mywin extends Frame ______
{
Button b = new Button("按钮");int x = 5;
Thread bird = null;
Mywin ()
{
setBounds(100,100,400,400); setLayout(new FlowLayout());
setTitle ("simple");
setVisible (true);
add(b);
b.setBackground (Color.green);
addWindowListener (new WindowAdapter () {
public void windowClosing(WindowEvent e)
{
System.exit (0);
}
});
bird = new Thread(this);
bird.start();
}
public ______
{
while (true)
{
x = x+1;
if(x > 100)
x = 5;
b.setBounds(40,40,x,x);
try
{
bird.sleep (200);
}
catch(InterruptedException e) {}
}
}
}