📜  如何对齐摆动元素 - 无论代码示例

📅  最后修改于: 2022-03-11 14:55:35.947000             🧑  作者: Mango

代码示例1
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.add(c1);
panel.add(c2);

c1.setAlignmentX(Component.LEFT_ALIGNMENT);
c2.setAlignmentX(Component.LEFT_ALIGNMENT);