如何在JavaFX中检测完成的调整大小操作? [英] how can one detect a finished resizing operation in JavaFX?

查看:88
本文介绍了如何在JavaFX中检测完成的调整大小操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个阶段,一个场景和一个 WebView 节点.当我将窗口扩大到更大的尺寸时,由于 WebView ,事情变得非常缓慢.我想做的是在窗口调整大小完成后,仅为 WebView 填充新空间(这是我在可调整大小的控件/边缘上释放鼠标左键的窗口).现在,我可以设置最大值.将此节点的大小设置为默认大小-这将阻止其扩展.但是,如何在窗口上检测到完成大小调整操作的实际事件?通过绑定,我可以验证调整大小的发生-但它是瞬时的(W& D的属性在不释放LMB的情况下立即更改),而我只需要在 LMB 被释放时执行操作.有建议吗?

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?

我尝试在阶段上为 Event.ANY 使用 addEventFilter ,只是为了查看此事件类型是否可识别-遗憾的是没有有用.

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.

推荐答案

仅当您能够使用在未经装饰的舞台上,您可以自己调整大小的装饰和操作;允许访问正确的钩子以处理调整大小操作的完成.

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.

请参见集成示例应用程序源中的WindowResizeButton类.演示如何在未装饰的舞台上实现调整大小句柄的演示代码.修改此类以添加 setOnMouseReleased 处理程序,并在其中实现对webView大小的修改.

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.

我确实想知道为什么这样做是有必要的,尽管我实际上没有调整包含WebView的窗口的大小,这可能是由于您的应用在WebView中的内容使用情况与我使用的内容不同.

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.

这篇关于如何在JavaFX中检测完成的调整大小操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆