这是一个小代码,应显示textarea并应显示我输入的内容.但我不知道它为什么不显示文字.当我按住任意键时,水平滚动条会移动,这意味着某些东西在那里,但没有任何东西显示出来.我正在使用JDK 1.8并在Windows 7 64位上使用记事本进行编辑.
public class tarea
{
public static void main (String[] args)
{
Frame f = new Frame("My Frame");
f.setLocation(100, 100);
f.setSize(500, 500);
f.setLayout(null);
f.setBackground(Color.BLACK);
f.setTitle("My area");
TextArea ta = new TextArea();
ta.setBounds(10, 10, 400, 400);
f.add(ta);
f.setVisible(true);
}
}
Run Code Online (Sandbox Code Playgroud)