我有一个带有 GUI 窗口的 Java 完整程序,当我按下最大化按钮以全屏显示我的 JTextArea 更大时,我想设置这个窗口。我在我的 GUI 中使用过
public final class Test extends javax.swing.JFrame {
private JLabel label1;
private JLabel label2;
private JLabel label3;
private JLabel label4;
private JLabel label5;
private JTextField field1;
private JTextField field2;
private JTextField field3;
private JButton button1;
private JButton button2;
private JButton button3;
private JButton button4;
private JScrollPane scrollpane;
private JTextArea visualization;
private JComboBox list;
public Program_GUI()
{
this.initialize_graphic_components();
}
public void initialize_graphic_components()
{
this.setTitle("Test Program");
this.setSize(600,400);
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
this.setMinimumSize(new Dimension(600,400));
this.setLayout(null);
this.label2=new JLabel("Username:");
this.label2.setBounds(20,50,120,20);
this.add(label2);
this.field2=new JTextField("");
this.field2.setBounds(20,70,120,20);
this.add(field2);
this.visualization = new JTextArea(420,250);
this.visualization.setEditable(false);
this.scrollpane=new JScrollPane(this.visualization);
this.scrollpane.setBounds(160, 50, 420, 250);
this.add(scrollpane);
............here is the rest program.........
}
这是我的程序的开始,当我按下最大化按钮时,我希望我的窗口伸展到显示器大小以保持一致。
谢谢。