菜鸟问题: 文本区不能显示(awt)。
CASE_ 2005-12-11 03:23:36 import java.awt.*;
import java.awt.event.*;
public class text1 extends WindowAdapter
{
private TextArea text;
public static void main(String argv[])
{
text1 t = new text1();
}
public text1()
{
Frame fra = new Frame("TEXT");
fra.setSize(700, 600);
fra.setLocation(200, 140);
fra.setBackground(Color.LIGHT_GRAY);
fra.setVisible(true);
text = new TextArea("", 40, 40, TextArea.SCROLLBARS_VERTICAL_ONLY);
fra.add(text);
fra.addWindowListener(this);
}
public void windowOpened(WindowEvent e)
{
text.setFont(new Font("Dialog", 0, 18));
}
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
运行时,为什么要改变一下窗体大小才能看到?