Reputation: 3679
I need to add some invisible component into a JPanel to avoid the issues with grid bag lay out.Which is the best way to add these kind of invisible components?
Upvotes: 0
Views: 1623
Reputation: 354714
You can use the helper methods of the Box class to create such components:
Box.createHorizontalStrut(int width)
:
Creates an invisible, fixed-width component.Box.createVerticalStrut(int height)
: Creates an invisible, fixed-height component.Adding them is done in exactly the same way as you add any other component.
Upvotes: 3
Reputation: 199264
Erhmmm you just add them?
Like in:
jpanel.add( youInvisibleComponent );
???
If you are having problems with the GridBagLayout, you should probably consider using another layout manager :(
Upvotes: 0
Reputation: 23273
My first question would be "why are you using a GridBayLayout?", have you looked at the alternatives, like GroupLayout?
Upvotes: 0