Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

detecting if a Frame is resized  RSS feed

 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a quick and easy built in method somewhere to detect whether the user has resized a Frame?
Thank you.
 
Avin Sinanan
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey dirk.. i don't know about that. But anyway I came up with some code that may be helpfull.
Heres what to do.. run the code. A small JFrame will appear. Drag the mouse around in it. TNotice the frame says "NOT RESIZED". Now resize the frame and move the mouse around " A differnt message shows.
However it works only once. Maybe you could develop it. Hope it helps.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the only ideas I've been able to come up with are:
1. As Avin has also suggested (thanks for the reply Avin), just explicitly keep track of the Frame's size;
or 2. take advantage of the automatic call to update(Graphics) - which more or less serves my purposes but of course this doesn't necessarily mean that the Frame has been resized.
 
Jeff Smith
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could add a ComponentListener to your JFrame. There's a componentResized() method that will allow you to do whatever it is you want to when the frame is resized.
Jeff
 
Daniel Searson
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try:

You get the idea...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!