0

I am currently programming a gui with JavaFX 2.0, which is resizable. When the user resizes the window, a big rectangle resizes with it. Now I need to push the new boundaries of this rectangle on to an image which floats inside the rectangle and may not cross its borders.

I thought of updating the boundaries via a ChangeListener, but I don't want it to update the boundaries that often. The perfect solution would be a "ChangeIsOverListener" which updates the boundaries once at the end of a change.

Can anybody help me out?

Thanks in advance! :)

Uluk Biy
  • 48,655
  • 13
  • 146
  • 153
user1582432
  • 725
  • 2
  • 7
  • 9
  • Related [http://stackoverflow.com/q/11377639/682495](http://stackoverflow.com/q/11377639/682495) – Uluk Biy Aug 08 '12 at 08:46
  • Bind events to stage width/height properties: [http://stackoverflow.com/questions/10773000/how-to-listen-for-resize-events-in-javafx][1] [1]: http://stackoverflow.com/questions/10773000/how-to-listen-for-resize-events-in-javafx – Tangocoder Aug 08 '12 at 13:42
  • i created an answer (including code!) for this here: http://stackoverflow.com/questions/10773000/how-to-listen-for-resize-events-in-javafx/25812859#25812859 – Chris Sep 12 '14 at 16:37

2 Answers2

1

You may be able to trap mouse-down and mouse-up events on either side of the window resizing - but whether you see those events will depend on the AWT system and may depend on the O/S too.

Otherwise you will have to use a timer within the window sizing event to trip a separate event some number of ms after the last window sizing event, such that you consider the size to be "done" if it hasn't be changed in the last, say, 1/2 a second. The amount of time will be a compromise between the user's perceived lag and the number of resizes you want to process.

Lawrence Dol
  • 63,018
  • 25
  • 139
  • 189
  • Thanks a lot! Is it possible to have a MouseUp-EventHandler inside of that ChangeEventHandler? That might be able to do the trick! http://stackoverflow.com/questions/11377639/how-can-one-detect-a-finished-resizing-operation-in-javafx?lq=1 (this goes in the same direction - just found it!) – user1582432 Aug 11 '12 at 12:59
0

Maybe you could compare the size of the window every x milliseconds, and when it doesn't change in this time interval, you know that the change is over.

laobeylu
  • 283
  • 3
  • 14