Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Gridlayout未根据约束调整大小_Java_Swing_User Interface_Jframe_Jbutton - Fatal编程技术网

Java Gridlayout未根据约束调整大小

Java Gridlayout未根据约束调整大小,java,swing,user-interface,jframe,jbutton,Java,Swing,User Interface,Jframe,Jbutton,本质上,我这里的问题是我的GridLayout没有创建我要求的6x4大小。它的尺寸是6x3,这是一张图片 您只向中心JPanel添加了18个组件,而不是24个。如果您想要4列和可变行数,请将GridLayout设置为新建GridLayout(0,4)程序中的其他地方很可能存在错误,代码未显示。您将希望创建并发布一个报告,让我们告诉您为什么会遇到这种错误行为。编辑:您只向您的中心JPanel添加了18个组件,而不是24个。如果需要4列和可变行数,请将GridLayout设置为新建GridLayou

本质上,我这里的问题是我的GridLayout没有创建我要求的6x4大小。它的尺寸是6x3,这是一张图片

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

程序中的其他地方很可能存在错误,代码未显示。您将希望创建并发布一个报告,让我们告诉您为什么会遇到这种错误行为。编辑:您只向您的中心JPanel添加了18个组件,而不是24个。如果需要4列和可变行数,请将GridLayout设置为
新建GridLayout(0,4)
。我将尝试使用可变行大小,这应该可以很好地工作。非常感谢。
    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.