开发者

Resizing a frame and its components when using NULL Layout

When using null layout, how to resize components?

I mean their position 开发者_开发百科and size. I know that using layout managers we need not take care of this issue. But my requirement is to move components in the panel. So I ought to use null layout.

Please let me know if you have ideas regarding finding new locations to place components on resize of the frame.


Doing Without a Layout Manager tutorial may help, although it is recommended that you use a layout manager, if at all possible.

Recommendations

  1. Either use a layout manager, or
  2. Register a ComponentListener and manually resize/position components when a resize event occurs.

The labor incurred with the latter approach may be enormous, and hence why using a layout manager comes highly recommended. Another, albeit cheap alternative (which I'm sure violates your requirements), is to invoke setResizable(false) on your JFrame.


for a component to be displayed in a null layout, they must of the bounds set on the component. They need a position(x,y) and a width/height

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜