ways to add invisible components into JPanel?
I need to add some invisible component into a JPanel to avoid the issues with grid bag lay out.Which is开发者_Go百科 the best way to add these kind of invisible components?
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.
My first question would be "why are you using a GridBayLayout?", have you looked at the alternatives, like GroupLayout?
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 :(
精彩评论