用户界面的GUI布局

时间:2013-10-04 23:09:16

标签: java swing layout user-interface

我正在尝试让用户界面页面在我的页面上正确显示。它必须在屏幕上显示某种方式,但我无法得到正确的布局显示。有什么建议或帮助吗?!我尝试了很多东西,但Java会让人感到有些困惑。附件是它如何支持的图像的链接

https://courses.eas.asu.edu/cse205/current/assignments/assignment6/assignment6.html

  public CreatePanel(Vector accountList, TransferPanel tPanel)
    {
   this.accountList = accountList;
   this.transferPanel = tPanel;



     JLabel label1 =new JLabel("Account ID: ");
     JLabel label2 = new JLabel("Amount: ");
     JTextField field1 = new JTextField();
     field1.setPreferredSize(new Dimension(250,70));
     JTextField field2 = new JTextField();
     field2.setPreferredSize(new Dimension(250,70));
     button1 = new JButton("Create an Account");
     JTextArea textArea = new JTextArea();
      textArea.setPreferredSize(new Dimension(500, 600));
      textArea.append("No account");
      textArea.setEditable(true);


      JPanel panel1 = new JPanel();
      panel1.setLayout(new GridLayout(3,3));
      panel1.add(label1);

      panel1.add(field1);

       panel1.add(label2);

       panel1.add(field2);



       JPanel panel2 = new JPanel();
      panel2.setLayout(new BorderLayout());
      panel2.add(button1, BorderLayout.SOUTH);



      JPanel panel3 = new JPanel();
      panel3.setLayout(new BorderLayout());
      panel3.add(textArea, BorderLayout.WEST);




     add(panel1);

     add(panel3);
     add(panel2);

  //ActionListener listener = new ButtonListener();
 //button1.addActionListener(listener);





    }

0 个答案:

没有答案