无法让JPanel显示整个内容

时间:2013-05-06 18:38:26

标签: java swing jpanel jbutton jtextfield

基本上,在Java中,我有3种不同的JPanel。 Panel 1中带有JTextField的Label, 面板2中的按钮面板, 面板3中的第二个JTextField。

在Panel 1中,我试图将标签放在JTextField的顶部,这样两个组件就可以在一个Panel中看到。当我将我的按钮添加到第二个面板时,面板2覆盖了TextField,或者说它不可见。我尝试将面板设置为不同的边框布局,并考虑尝试SpringLayout,尽管Label被覆盖,或者是JTextField本身。

这种困境是否有答案或者我没有尝试过? [已添加代码]

    public class Finale extends JApplet implements ActionListener{
private JButton PostP1 = new JButton("Post Position 1");
private JButton PostP2 = new JButton("Post Position 2");
private JButton PostP3 = new JButton("Post Position 3");
private JButton PostP4 = new JButton("Post Position 4");
private JTextField ReadOut = new JTextField("Hello");
    public Finale(){
      JPanel LabelPane = new JPanel();
  JPanel ButtonPane = new JPanel();
      ButtonPane.add(PostP1);
  ButtonPane.add(PostP2);
  ButtonPane.add(PostP3);
  ButtonPane.add(PostP4);
      JLabel Welcome = new JLabel("example text");
      LabelPane.add(Welcome);
      LabelPane.add(ReadOut);
      add(LabelPane, BorderLayout.NORTH);
  add(ButtonPane, BorderLayout.SOUTH);

    }

0 个答案:

没有答案
相关问题