【发布时间】:2011-02-14 17:52:27
【问题描述】:
我在java中使用BoxLayout布局管理器,并对齐了一堆组件:
myLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
myTextBox.setAlignmentX(Component.LEFT_ALIGNMENT);
myButton.setAlignmentX(Component.LEFT_ALIGNMENT);
...
我有很多组件,这似乎是最重要的。有速记方式吗?
我尝试了以下方法,但 setAlignmentX 不是 Component 内部的方法?
for (Component c : personPanel.getComponents()) {
c.setAlignmentX(Component.LEFT_ALIGNMENT);
}
【问题讨论】:
标签: java swing user-interface alignment