Tag: flowlayout

为什么我的组件不包装在Swing的FlowLayout中?

为什么我的组件不使用FlowLayout包装在这个JPanel中? 它们只是在屏幕上运行,只是部分可见。 JPanel panel = new JPanel(new FlowLayout()); panel.add(new JLabel(“TEST”)); // … repeat adding JLabels until they go off screen when they SHOULD wrap // to the next line… 这是我的全部代码(除了添加和打包框架)。 我误解了FlowLayout吗? 我是否必须在标签或面板上设置某种尺寸?

将组件设置在页面的中心

如何在面板中央设置组件(比如按钮)? 我使用Flowlayout将布局约束作为中心,但我在面板的顶部中心位置获得了按钮。