2

I know I can use componentResized to listen for when the user resizes a window. This isn't a very nice solution. If I do this and add a resize() method for the children components, then it waits until the user finishes the resizing before it calls the resize() method. Is there a way to resize the child elements as the resize happens?

plalx
  • 42,889
  • 6
  • 74
  • 90

1 Answers1

1

The listener with componentResized() is the nice solution. Using listener in swing isn't a bad solution at all.

You can see the solution you want on oracle.com

Colin Hebert
  • 91,525
  • 15
  • 160
  • 151
  • My problem is, if the user resizes the window from 600px to 800px, the components inside will not resize until the user has finished resizing. It looks damn terrible. I am seeking something that will resize the components with the window. –  Oct 12 '10 at 21:40
  • usually component are resizing at the same time as the container (see the example given in the answer). – Colin Hebert Oct 12 '10 at 21:42
  • I was adding the listener to my window and not my JPanel, that was my problem. –  Oct 12 '10 at 21:50