• Post Reply Bookmark Topic Watch Topic
  • New Topic

Any RESIZE listener there???

 
Prosenjit Banerjee
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Can anybody please tell me what interface to implement and what method to override in order to execute codes while a JFrame is being resized by dragging its border with mouse?
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's swing from SCJP to Swing...
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ComponentListener
 
Prosenjit Banerjee
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Barry, for your swing business, I shall remember to post at the right place.

Also thanks to Michael but that does not solve my problem. There is a method called componentResized(), but that is called after a component has been resized. I was asking for a method while I am resizing a component and not after resize.

Please try to help me.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
haven't heard of an event 'while resizing', but not too hard to simulate

JFrame.setDefaultLookAndFeelDecorated(true);
construct a JFrame
add a MouseMotionListener to the frame
in mouseDragged() compare frame's width/height to previous numbers
if(width or height <> old numbers) its being resized
else its just being moved
 
Prosenjit Banerjee
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again Michael. But this time also it didn't work. As it turns out, when you are resizing a frame by holding and dragging one of it's borders using mouse, the mouseDragged() method is not getting called, only it is called when you are actually dragging the mouse on the body of the frame as the following code suggests:


[ September 03, 2006: Message edited by: Prosenjit Banerjee ]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Prosenjit Banerjee
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Michael, I missed that. But, thank you very much, I learnt a new thing. It works! I am happy but dissppointed at the same time. Because I could not do it with the default look and feel. Only in order to provide the very common resizing event I had to change the total look and feel of a frame! Frankly, that is not really desired.

Again, I wonder how things like this can be known (e.g. that a decorated laf supports risize event)? Is there any such documentation?
[ September 04, 2006: Message edited by: Prosenjit Banerjee ]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> Is there any such documentation?

I haven't come across any.


> I wonder how things like this can be known (e.g. that a decorated laf supports risize event)?

one way is to read lots of posts at various java forums, and experimenting.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!