Link to home
Start Free TrialLog in
Avatar of frube
frubeFlag for United Kingdom of Great Britain and Northern Ireland

asked on

JFrame Resize Event

Hi, I am designing a GUI with my own custom JTable which has a method to resize the columns in the table, such that the 2nd column fills all of the space that the JTable has available. I have added a listener to the main JFrame to detect when it is resized so I can call my resize method.

I'm aware that you can set the .setDynamicLayout() to true for the default toolkit to enable components to be resized and moved according to the layout manager as the frame is being resized (instead of just when the user releases the mouse button after a resize)

My problem is that the listener I have registered only picks up resize events fired after the user releases the mouse button after a resize. Is there a way to call my .resize() method dynamically as the JFrame is being resized?
ASKER CERTIFIED SOLUTION
Avatar of StillUnAware
StillUnAware
Flag of Lithuania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of hoomanv
hoomanv
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of frube

ASKER

To StillUnAware; Thanks, but I compiled that code you supplied and it doesn't seem to work at all, the components are repositioned after you release the mouse click (which is not what I was looking for, see original post.) I do hope this is possible, it would make the effect on the table is currently quite ugly while being resized, the scrollbars come into view and disappear again when my resize() method is called, it's not very professional-looking.

To hoomanv; Thank you, but I'm not sure if you read my question in full, I am already using dynamic layout for the frame, the problem is calling a method continuously each time the layout is adjusted dynamically. The link you provided doesn’t suggest whether this can or can not be achieved.
AFAIK no pure java way is available to trap the resizing event
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of frube

ASKER

To mayankeagle, if you read the first paragraph, quoting myself here; "I have added a listener to the main JFrame to detect when it is resized so I can call my resize method"
Yes but you didn't mention what type of listener it is and you didn't post any code sample as to how you are using it.