I have a stage, a scene and a WebView node. When I expand the window to a larger size - things get pretty sluggish due to WebView. What I want to do is fill the new space for WebView only when the resizing of the window has been finished (this is me releasing left mouse button on the resizable control/edge of the window). For now I can just set the max. size of this node to what it is by default - this will stop it from expansion. But how can I detect the actual event of a completed resizing operation on the window? With binding, I can verify that the resizing takes place - but it's instantaneous (properties for W & D change immediately w/o releasing LMB), while I only require an action when the LMB has been released. Suggestions?
I tried using an addEventFilter on the stage for Event.ANY, just to see if this event type is recognizable - sadly with no avail.
I've also stumbled upon this unanswered post.
I am making an application where I have to periodically fetch satellite imagery (rather intensive), so I had to find a way to capture only the last event as well. I settled on spawning a thread to count down for some length of time before executing the intensive task and a resize-listener that resets the count. It seems more efficient to me than scheduling and unscheduling tasks hundreds of times.
Note I've also got some logic in here to capture the first window-size-change with System.currentTimeMillis();
This answer is only applies if you are able to use an undecorated Stage for your application.
With an undecorated stage you can handle the resizing decorations and operations yourself; allowing access to the right hooks for handling the completion of a resize operation.
See the WindowResizeButton class in the Ensemble sample application source code for a demo of how to implement a resize handle for an undecorated stage. Modify this class to add a setOnMouseReleased handler and implement your webView size modifications in there.
I do wonder why this is necessary though as I haven't really had any sluggishness resizing a Window containing WebView - perhaps this is due to your app having different content usage in the WebView from what I have been using.
This is not a direct answer to your question. If I understood the sluggishness correctly you are facing somekind weird flashings and renderings. To reduce the sluggishness the size of the webView can be updated manually and more sparsely:
The webView is in the
Pane
which does not layout its children automatically. The webView's size updating is delayed for .5 second ignoring updates in interval.