问题:运行后,没有按钮,没有文本框。我检查了n多遍,实在找不出问题,大伙帮忙给看看。
import java.awt.*;
import java.awt.event.*;
class myWindowDemo
{
private Frame f;
private TextField tf;
private Button b;
private TextArea ta;
myWindowDemo()
{
init();
}
public void init()
{
f=new Frame("my window");
f.setBounds(300,100,500,500);
tf=new TextField(30);
b=new Button("转到");
ta=new TextArea(10,20);
f.add(tf);
f.add(b);
f.add(ta);
myEvent();
f.setVisible(true);
}
public void myEvent()
{
f.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
public static void main(String[] args)
{
new myWindowDemo();
}
}
|