refresh JFrame after adding new Components

reox picture reox · Sep 15, 2010 · Viewed 95.3k times · Source

I want to add some new Components to my JFrame during runtime when a button is pressed. This works so far, but i have to resize the window manually to see the new components.

Is there any Action I can fire or a method to call to refresh the window? Any help appreciated. Thanks in advance.

Answer

crusam picture crusam · Sep 15, 2010

You have to revalidate(); the frame. If that doesn't work you also have to call repaint();