Java Gridlayout未根据约束调整大小
本质上,我这里的问题是我的GridLayout没有创建我要求的6x4大小。它的尺寸是6x3,这是一张图片 您只向中心JPanel添加了18个组件,而不是24个。如果您想要4列和可变行数,请将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(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.