import java.awt.*;
import java.awt.event.*;
class FrameDemo2
{
private Frame f;
private Button b;
FrameDemo2()
{
init();
}
public void init()
{
Frame f=new Frame("my frame");
f.setSize(300,300);
f.setLocation(243,243);
f.setLayout(new FlowLayout());
Button b=new Button("i am a button");
f.add(b);
myEvent();
f.setVisible(true);
}
private void myEvent()
{
f.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
public static void main(String[] args)
{
new FrameDemo2();
}
}
啥情况,看了半天没看出来,求解。
|
|