tags:

views:

87

answers:

2

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 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?

+1  A: 
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

goatlinks
thanks, I get it [:-)]
Johanna
Excuse me,if I have lots of frames what should I do??
Johanna
You can also call frame.setSize(int width, int height); on each of them to set their sizes explicitly.If this isn't possible, then invalidate() should mark the frames as needing to be laid out. This will cause your layout manager to reposition and size everything in the frame.
goatlinks
A: 

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.

Suraj Chandran