SceneBuilder 无法打开使用 JFoenix 元素的 FXML 文件

问题描述 投票:0回答:1

尝试在 SceneBuilder 中打开 FXML 文件时,抛出异常。有办法解决这个问题吗?

Java:
11.0.19 2023-04-18 LTS

场景生成器:
版本20.0.0
日期:2023-05-08 14:08:52
JavaFX 版本:20.0.1
Java 版本:20,OpenJDK 运行时环境

JFoenix:
jfoenix-8.0.10.jar
jfoenix-9.0.10.jar
jfoenix-17.0.2.jar
jfoenix-17.0.5.jar
jfoenix-19.0.1.jar
(以上均不起作用)


java.lang.NullPointerException: Cannot invoke "javafx.scene.Node.getLayoutBounds()" because "this.textNode" is null
    at com.jfoenix.skins.JFXTextFieldSkin.updateTextPos(JFXTextFieldSkin.java:109)
    at com.jfoenix.skins.JFXTextFieldSkin.layoutChildren(JFXTextFieldSkin.java:93)
    at [email protected]/javafx.scene.control.Control.layoutChildren(Unknown Source)
    at [email protected]/javafx.scene.Parent.layout(Unknown Source)
    at [email protected]/javafx.scene.Parent.layout(Unknown Source)
    at [email protected]/javafx.scene.Parent.layout(Unknown Source)
    at [email protected]/javafx.scene.Parent.layout(Unknown Source)
    at [email protected]/javafx.scene.Parent.layout(Unknown Source)
    at [email protected]/javafx.scene.SubScene.layoutPass(Unknown Source)
    at [email protected]/javafx.scene.Parent.layout(Unknown Source)
    at [email protected]/javafx.scene.Parent.layout(Unknown Source)
    at [email protected]/javafx.scene.Group.prefWidth(Unknown Source)
    at [email protected]/javafx.scene.Group.minWidth(Unknown Source)
    at [email protected]/javafx.scene.layout.Region.computeChildPrefAreaWidth(Unknown Source)
    at [email protected]/javafx.scene.layout.Region.getMaxAreaWidth(Unknown Source)
    at [email protected]/javafx.scene.layout.Region.computeMaxPrefAreaWidth(Unknown Source)
    at [email protected]/javafx.scene.layout.StackPane.computePrefWidth(Unknown Source)
    at [email protected]/javafx.scene.Parent.prefWidth(Unknown Source)
    at [email protected]/javafx.scene.layout.Region.prefWidth(Unknown Source)
    at [email protected]/javafx.scene.layout.Region.minWidth(Unknown Source)
    at [email protected]/javafx.scene.control.skin.ScrollPaneSkin.computeScrollNodeSize(Unknown Source)
    at [email protected]/javafx.scene.control.skin.ScrollPaneSkin.layoutChildren(Unknown Source)
    at [email protected]/javafx.scene.control.Control.layoutChildren(Unknown Source)
    at [email protected]/javafx.scene.Parent.layout(Unknown Source)
    at [email protected]/javafx.scene.Parent.layout(Unknown Source)
    at [email protected]/javafx.scene.Parent.layout(Unknown Source)
    at [email protected]/javafx.scene.Parent.layout(Unknown Source)
    at [email protected]/javafx.scene.Parent.layout(Unknown Source)
    at [email protected]/javafx.scene.Parent.layout(Unknown Source)
    at [email protected]/javafx.scene.Parent.layout(Unknown Source)
    at [email protected]/javafx.scene.Parent.layout(Unknown Source)
    at [email protected]/javafx.scene.Scene.doLayoutPass(Unknown Source)
    at [email protected]/javafx.scene.Scene.preferredSize(Unknown Source)
    at [email protected]/javafx.scene.Scene$2.preferredSize(Unknown Source)
    at [email protected]/com.sun.javafx.scene.SceneHelper.preferredSize(Unknown Source)
    at [email protected]/javafx.stage.Window$12.invalidated(Unknown Source)
    at [email protected]/javafx.beans.property.BooleanPropertyBase.markInvalid(Unknown Source)
    at [email protected]/javafx.beans.property.BooleanPropertyBase.set(Unknown Source)
    at [email protected]/javafx.stage.Window.setShowing(Unknown Source)
    at [email protected]/javafx.stage.Window.show(Unknown Source)
    at [email protected]/javafx.stage.Stage.show(Unknown Source)
    at com.oracle.javafx.scenebuilder.kit.editor.panel.util.AbstractWindowController.openWindow(AbstractWindowController.java:152)
    at com.oracle.javafx.scenebuilder.app.DocumentWindowController.openWindow(DocumentWindowController.java:1228)
    at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.performOpenFiles(SceneBuilderApp.java:675)
    at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.handleOpenFilesAction(SceneBuilderApp.java:513)
    at com.oracle.javafx.scenebuilder.app.welcomedialog.WelcomeDialogWindowController.handleOpen(WelcomeDialogWindowController.java:221)
    at com.oracle.javafx.scenebuilder.app.welcomedialog.WelcomeDialogWindowController.fireOpenRecentProject(WelcomeDialogWindowController.java:194)
    at com.oracle.javafx.scenebuilder.app.welcomedialog.WelcomeDialogWindowController.lambda$loadAndPopulateRecentItemsInBackground$2(WelcomeDialogWindowController.java:155)
    at [email protected]/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
    at [email protected]/com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
    at [email protected]/javafx.event.Event.fireEvent(Unknown Source)
    at [email protected]/javafx.scene.Node.fireEvent(Unknown Source)
    at [email protected]/javafx.scene.control.Button.fire(Unknown Source)
    at [email protected]/com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(Unknown Source)
    at [email protected]/com.sun.javafx.scene.control.inputmap.InputMap.handle(Unknown Source)
    at [email protected]/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at [email protected]/com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
    at [email protected]/com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
    at [email protected]/javafx.event.Event.fireEvent(Unknown Source)
    at [email protected]/javafx.scene.Scene$MouseHandler.process(Unknown Source)
    at [email protected]/javafx.scene.Scene.processMouseEvent(Unknown Source)
    at [email protected]/javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
    at [email protected]/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
    at [email protected]/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Unknown Source)
    at [email protected]/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(Unknown Source)
    at [email protected]/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(Unknown Source)
    at [email protected]/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
    at [email protected]/com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
    at [email protected]/com.sun.glass.ui.View.notifyMouse(Unknown Source)
    at [email protected]/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at [email protected]/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)
java javafx fxml scenebuilder jfoenix
1个回答
0
投票

建议

使用 MaterialFX 来代替。

已知一些 JFoenix 组件在最近的 SceneBuilder 版本和使用 JavaFX 版本中被破坏 < 16.

说明

堆栈跟踪显示 JFoenix 代码中出现的错误,而不是您的代码中出现的错误。

https://github.com/bisq-network/bisq/pull/5835

运行桌面应用程序仅适用于 JDK 11 至 15,直到 sshahine/JFoenix#1205 得到修复。现在,尝试在 JDK 16+ 上运行将导致无法调用“javafx.scene.Node.getLayoutBounds()”,因为“this.textNode”为空错误。

我还能用JFoenix吗

也许可以尝试这里的解决方案:

即为您的运行时降级到 JavaFX 15,同时降级到在 JavaFX 15 上运行的 SceneBuilder 的早期版本。

如果他们让 Gluon 找到在 JavaFX 15 或更早版本上运行的版本,您将需要尝试 Gluon 的各种存档版本,因为所有更高版本的 SceneBuilder 版本都使用 JavaFX 17 或更高版本,而这不适用于 JFoenix。

常见问题解答

我已经制作了数百个 FXML 文件,它们正在使用 JFoenix 组件。这是否意味着我必须全部更换?该应用程序已投入生产并部署到许多客户,这让我面临进行如此大的更改的风险。

那就很难了。您可能需要更改工作流程以在文本编辑器而不是 SceneBuilder 中手动编辑一些 fxml 文件。有些 IDE(例如 Idea)提供了智能编辑支持,可以提供帮助。

随着时间的推移,如果您想继续维护应用程序而不是按原样冻结或停用它,那么计划从 JFoenix 迁移到 MaterialFX。

我可以在调试器中调试这个问题吗?

除非您在调试器中运行 SceneBuilder 和 JFoenix 代码,否则断点不会有帮助,我真的不推荐这样做。

我可以修复 JFoenix 库吗?

您也许可以从堆栈跟踪中找出 JFoenix 代码中的错误和不兼容之处,然后在 JFoenix 库的自定义版本中修复它,但这并不是唯一与最新场景生成器版本不兼容的控件,您可能必须在 JFoenix 中修补和修复多个问题。

目前我不认为 JFoenix 存储库处于活动状态,因此支持请求可能不会被执行(这可能会随着时间的推移而改变)。

© www.soinside.com 2019 - 2024. All rights reserved.