Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What methods get called when you resize a JFrame?

Tags:

java

swing

I'm using a JFrame in which the CENTER portion of the BorderLayout is occupied by a JScrollPane that wraps around a JPanel. What I'm finding is that when I initiate the action that actually causes the JPanel to be displayed, the display doesn't change. But when I resize the JFrame, the new JScrollPane has now magically appeared.

So what methods are called when you resize a JFrame? If I know, then I can call it in the code and avoid having to resize the frame just to see the results of the operation.

like image 568
Mitch Flax Avatar asked Oct 14 '22 18:10

Mitch Flax


1 Answers

Its been a little bit since I've done swing, but from memory, calling validate() on the panel should do the trick. This will cause it and its children to have their layout calculated which is when the scrollbars decision is made. If that doesn't work, try calling validate on the frame's content pane. This is a little more costly, but may be needed if other components are being considered.

like image 118
AdamC Avatar answered Oct 20 '22 15:10

AdamC