开发者

How can I change the size of frame?

I have a frame which has a menu item for choosing the font and its size, when the user choose her/his font size, all开发者_Go百科 the text of buttons, panels, which are in my program (has many frames) will be changed but they will be bigger than the size of frames. What should I do for changing the size of my frames at run-time?

Edit: Also with using pack method, how can I call it in my mainFrame to change all the other frames?


frame.pack();

This:

"Causes this Window to be sized to fit the preferred size and layouts
of its subcomponents. If the window and/or its owner are not yet displayable,
both are made displayable before calculating the preferred size. The Window
will be validated after the preferredSize is calculated."

See Here


Try using :

validate() and invalidate() methods

frame.pack() will pack to the best-fit-preferred-size as decided internally. Sometimes this is not what you want. Instead I would suggest using validate() and invalidate() methods, which will relayout the contents of your frame with the new sizes.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜