• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Any RESIZE listener there???

 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's swing from SCJP to Swing...
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ComponentListener
 
Prosenjit Banerjee
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Prosenjit Banerjee
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
a fool thinks himself to be wise, but a wise man knows himself to be a fool - shakespeare. foolish tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic