Gridlayout没有限制到约束

时间:2014-02-11 17:53:29

标签: java swing user-interface jframe jbutton

    this.setSize(700,500);
    this.setLayout(new BorderLayout());
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setIconImage(frameIcon.getImage());
    this.setTitle("Rifle Reload Logger v1.0");
    this.setMinimumSize(new Dimension(700,500));
     /*
    * The center panel of the JFrame will be used to display the current information
    * as needed whether it be for showing the file chooser, or the reload data.*/
    center.setVisible(true);
    center.setLayout(new GridLayout(6,4));
    this.add(center, BorderLayout.CENTER);
    setGUILabels();//sets the labels for the entire Gui.

基本上我的问题是我的GridLayout没有创建我要求它的6x4大小。它是一个6x3大小,这是一个图像。 Improper gridlayout.

1 个答案:

答案 0 :(得分:1)

您只向中心JPanel添加了18个组件,而不是24个。如果您想要4列和可变数量的行,请将GridLayout设置为new GridLayout(0, 4)