JTextArea有一个publicJTextArea(Stringtext,introws,intcolumns)的构造函数,text就可以表示默认文字,rows表示行数,colums表示列数。也可以在显示之前调用 publicvoidsetText(Stringt)方法设置。例如像下面这样:public class WinTest7{ public static void main(String[] args) { JFrame frame = new JFrame(); JTextArea area = new JTextArea("welcom to textarea!",40,50); area.setText("this is new default String"); frame.add(area); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setLayout(new FlowLayout()); frame.setVisible(true); }}
阅读全文 >