我在一BoxLayout组中有四个按钮.这只是两个样本,因为它都是重复的代码.我想在每个按钮之间创建一个小空间,这样它们就不会相互碰撞.我几乎尝试了所有方法,但.add(Box.Create....)没有任何效果.
enter.add(Box.createVerticalGlue());
enter.add(Box.createHorizontalGlue());
//enter.add(new JSeparator(SwingConstants.HORIZONTAL));
JButton float = new JButton("LOWER");
float.add(Box.createVerticalGlue());
float.add(Box.createHorizontalGlue());
Run Code Online (Sandbox Code Playgroud)