Pregunta

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! :)

¿Fue útil?

Solución

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.

Otros consejos

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top