开发者

ways to add invisible components into JPanel?

开发者 https://www.devze.com 2022-12-11 01:16 出处:网络
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 metho

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 :(

0

精彩评论

暂无评论...
验证码 换一张
取 消