调整应用程序窗口大小后,JavaFX UI元素悬停样式无法正确呈现 [英] JavaFX UI elements hover style not rendering correctly after resizing application window

查看:193
本文介绍了调整应用程序窗口大小后,JavaFX UI元素悬停样式无法正确呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,具有悬停样式的某些UI元素根本不会渲染,并且会在其中留下白色框。这仅在我调整应用程序窗口大小并且UI元素完全超出应用程序窗口的原始边界之后才会发生。从鼠标悬停位置移除鼠标指针后,下图中显示的按钮也无法立即正确呈现,因此只要按钮需要重新绘制,就可能出现问题。

At times, certain UI elements that have a hover style will not render at all and a white box is left in it's place. This only happens after I resize the application window and when the UI element is completely outside of the original bounds of the application window. The button shown in the images below also does not immediately render correctly after removing the mouse pointer from the hover position, so the issue likely would occur whenever the button needs to be repainted.

鼠标悬停设备记录按钮,然后再调整窗口大小。

调整窗口大小后。 设备记录和其他测试按钮都是窗口原始边界的100%。但是,云服务器迁移按钮仍然可以正确呈现。

我已设置样式,但删除它们无效。只有在进行其他处理时才会出现此问题,例如运行固件更新功能。这告诉我可能会占用UI时间,但我希望这会影响每个UI元素,而不仅仅是某些元素。

I have set styles, but removing them has no effect. The issue only seems to appear when there is other processing taking place, such as running the firmware update function. That tells me that there may be something taking up UI time, but I would have expected that to affect every UI element, not just certain ones.

另一个注意事项, UI已从Swing转换为JavaFX,因此所有线程都不包括使用Task或Platform.runlater()。我已经确保所有UI更新都使用Platform.runlater(),但我还没有将所有未更新UI的原始线程转换为Tasks。下面我将介绍运行固件更新的框架。

One other note, the UI was converted from Swing to JavaFX, so all of the threading did not include the use of Task or Platform.runlater(). I have since made sure all UI updates are using Platform.runlater(), but I have not yet converted all of the original threads that don't update the UI to Tasks. Below I am including the framework of running a firmware update.

编辑:能够在不启动固件更新的情况下重现问题,因此我认为它没有任何内容处理阻止UI渲染。仅在使用某些UI后才会出现此问题。因此,我删除了上面发布的代码。这让我相信它更多地与UI的实际布局有关。

Was able to reproduce the issue without starting a firmware update, so I don't think it has anything to do with processing blocking UI rendering. The issue occurred only after using some of the UI. As such I removed the code that was posted above. This leads me to believe it has more to do with the actual layout of the UI.

推荐答案

我相信我已经找到了问题。我使用ListView来保存Object和cellfactory以使用自定义UI呈现每个单元格。使用项目填充列表时,会生成其他线程以检索单元格中每个对象的信息。与Object关联的变量绑定到自定义UI中的视图属性。我没有使用Platform.runlater()来使用新信息更新这些属性。将套件更新为runlater后,问题似乎已得到解决。

I believe I have figured out the issue. I use a ListView to hold an Object and a cellfactory to render each of the cells with a custom UI. When populating the list with items, additional threads are spawned to retrieve information for each Object within the cell. The variables associated with the Object are bound to a view property within the custom UI. I was not using Platform.runlater() to update these properties with the new information. After updating the sets to runlater, the issue appears to have been fixed.

这篇关于调整应用程序窗口大小后,JavaFX UI元素悬停样式无法正确呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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