Aligning all panel components java
Posted
by destructo_gold
on Stack Overflow
See other posts from Stack Overflow
or by destructo_gold
Published on 2010-05-02T11:05:43Z
Indexed on
2010/05/02
11:17 UTC
Read the original article
Hit count: 140
I am using the BoxLayout layout manager in java, and have aligned a bunch of components:
myLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
myTextBox.setAlignmentX(Component.LEFT_ALIGNMENT);
myButton.setAlignmentX(Component.LEFT_ALIGNMENT);
...
I have a lot of components, and this seems over the top. Is there a shorthand way?
I tried the following, but setAlignmentX isn't a method inside Component?
for (Component c : personPanel.getComponents()) {
c.setAlignmentX(Component.LEFT_ALIGNMENT);
}
© Stack Overflow or respective owner