gpt4 book ai didi

JavaFX TreeView java.lang.RuntimeException

转载 作者:行者123 更新时间:2023-12-04 15:06:57 26 4
gpt4 key购买 nike

在运行演示 TreeView 控件使用的简单程序时,出现以下异常:

java.lang.RuntimeException:创建节点时出错:类 javafx.scene.layout.StackPane id:null

使用子项展开或关闭 TreeItem 时会发生此错误。

这是 SSCCE:

import static javafx.application.Application.launch;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.stage.Stage;
public class TreeViewTest extends Application {
Tab treeTab;
@Override
public void start(Stage primaryStage) throws Exception {
TabPane pane = new TabPane();
Scene scene = new Scene(pane,800,600);
treeTab = new Tab("Tree");
pane.getTabs().addAll(treeTab);
primaryStage.setTitle("F(X)yz - Collision Test");
primaryStage.setScene(scene);
primaryStage.show();
makeTree();
}
private void makeTree(){
TreeItem<String> treeItemRoot = new TreeItem<> ("Root");
TreeItem<String> nodeItemA = new TreeItem<>("Item A");
TreeItem<String> nodeItemB = new TreeItem<>("Item B");
TreeItem<String> nodeItemC = new TreeItem<>("Item C");
treeItemRoot.getChildren().addAll(nodeItemA, nodeItemB, nodeItemC);
TreeItem<String> nodeItemCA = new TreeItem<>("Item CA");
TreeItem<String> nodeItemCB = new TreeItem<>("Item CB");
nodeItemC.getChildren().addAll(nodeItemCA, nodeItemCB);
TreeItem<String> nodeItemA1 = new TreeItem<>("Item A1");
TreeItem<String> nodeItemA2 = new TreeItem<>("Item A2");
TreeItem<String> nodeItemA3 = new TreeItem<>("Item A3");
nodeItemA.getChildren().addAll(nodeItemA1, nodeItemA2, nodeItemA3);
TreeView<String> treeView = new TreeView<>(treeItemRoot);
treeTab.setContent(treeView);
}
public static void main(String[] args) {
launch(args);
}
}

这是在 WINdows 7 上的 Netbeans 8.2 中的 jdk1.8.0_162 上运行的。

请任何人都可以提出改进建议以消除错误。
谢谢。

PS堆栈跟踪:
java.lang.RuntimeException: Error while creating node:class javafx.scene.layout.StackPane id:null
NODE INFORMATION
Node:StackPane@5bb0a705[styleClass=tree-disclosure-node] Class:class javafx.scene.layout.StackPane Id:null
Children:[StackPane@401249ef[styleClass=arrow]]
PARENT INFORMATION
Node:TreeViewSkin$1@72fac9c9[styleClass=cell indexed-cell tree-cell]'Root' Class:class com.sun.javafx.scene.control.skin.TreeViewSkin$1 Id:null
Children:[Text[text="Root", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL_VERTICAL_CENTER, font=Font[name=System Regular, family=System, style=Regular, size=15.0], fontSmoothingType=LCD, fill=0x333333ff]]

at org.fxconnector.node.SVNodeFactory.createNode(SVNodeFactory.java:56)
at org.fxconnector.StageControllerImpl.createNode(StageControllerImpl.java:775)
at org.fxconnector.StageControllerImpl.lambda$new$10(StageControllerImpl.java:231)
at com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329)
at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
at javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:233)
at javafx.collections.FXCollections$UnmodifiableObservableListImpl.lambda$new$62(FXCollections.java:929)
at javafx.collections.WeakListChangeListener.onChanged(WeakListChangeListener.java:88)
at com.sun.javafx.collections.ListListenerHelper$SingleChange.fireValueChangedEvent(ListListenerHelper.java:164)
at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
at com.sun.javafx.collections.VetoableListDecorator.lambda$new$31(VetoableListDecorator.java:76)
at com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329)
at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
at javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:233)
at javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
at javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
at javafx.collections.ObservableListBase.endChange(ObservableListBase.java:205)
at javafx.collections.ModifiableObservableListBase.remove(ModifiableObservableListBase.java:183)
at com.sun.javafx.collections.VetoableListDecorator.remove(VetoableListDecorator.java:332)
at com.sun.javafx.collections.VetoableListDecorator.remove(VetoableListDecorator.java:221)
at javafx.scene.Parent.impl_toBack(Parent.java:644)
at javafx.scene.Node.toBack(Node.java:1756)
at com.sun.javafx.scene.control.skin.TreeCellSkin.updateDisclosureNode(TreeCellSkin.java:186)
at com.sun.javafx.scene.control.skin.TreeCellSkin.layoutChildren(TreeCellSkin.java:211)
at javafx.scene.control.Control.layoutChildren(Control.java:578)
at javafx.scene.Parent.layout(Parent.java:1087)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Scene.doLayoutPass(Scene.java:552)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2397)
at com.sun.javafx.tk.Toolkit.lambda$runPulse$29(Toolkit.java:398)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:397)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:424)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:518)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:498)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:491)
at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$403(QuantumToolkit.java:319)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
java.lang.RuntimeException: Error while creating node:class javafx.scene.layout.StackPane id:null
NODE INFORMATION
Node:StackPane@3fb4f2e2[styleClass=tree-disclosure-node] Class:class javafx.scene.layout.StackPane Id:null
Children:[StackPane@b52262b[styleClass=arrow]]
PARENT INFORMATION
Node:TreeViewSkin$1@330b4596[styleClass=cell indexed-cell tree-cell]'Item A' Class:class com.sun.javafx.scene.control.skin.TreeViewSkin$1 Id:null
Children:[Text[text="", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL_VERTICAL_CENTER, font=Font[name=System Regular, family=System, style=Regular, size=15.0], fontSmoothingType=LCD, fill=0x333333ff]]

at org.fxconnector.node.SVNodeFactory.createNode(SVNodeFactory.java:56)
at org.fxconnector.StageControllerImpl.createNode(StageControllerImpl.java:775)
at org.fxconnector.StageControllerImpl.lambda$new$10(StageControllerImpl.java:231)
at com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329)
at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
at javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:233)
at javafx.collections.FXCollections$UnmodifiableObservableListImpl.lambda$new$62(FXCollections.java:929)
at javafx.collections.WeakListChangeListener.onChanged(WeakListChangeListener.java:88)
at com.sun.javafx.collections.ListListenerHelper$SingleChange.fireValueChangedEvent(ListListenerHelper.java:164)
at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
at com.sun.javafx.collections.VetoableListDecorator.lambda$new$31(VetoableListDecorator.java:76)
at com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329)
at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
at javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:233)
at javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
at javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
at javafx.collections.ObservableListBase.endChange(ObservableListBase.java:205)
at javafx.collections.ModifiableObservableListBase.remove(ModifiableObservableListBase.java:183)
at com.sun.javafx.collections.VetoableListDecorator.remove(VetoableListDecorator.java:332)
at com.sun.javafx.collections.VetoableListDecorator.remove(VetoableListDecorator.java:221)
at javafx.scene.Parent.impl_toBack(Parent.java:644)
at javafx.scene.Node.toBack(Node.java:1756)
at com.sun.javafx.scene.control.skin.TreeCellSkin.updateDisclosureNode(TreeCellSkin.java:186)
at com.sun.javafx.scene.control.skin.TreeCellSkin.layoutChildren(TreeCellSkin.java:211)
at javafx.scene.control.Control.layoutChildren(Control.java:578)
at javafx.scene.Parent.layout(Parent.java:1087)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Scene.doLayoutPass(Scene.java:552)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2397)
at com.sun.javafx.tk.Toolkit.lambda$runPulse$29(Toolkit.java:398)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:397)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:424)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:518)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:498)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:491)
at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$403(QuantumToolkit.java:319)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
java.lang.RuntimeException: Error while creating node:class javafx.scene.layout.StackPane id:null
NODE INFORMATION
Node:StackPane@4a2a9995[styleClass=tree-disclosure-node] Class:class javafx.scene.layout.StackPane Id:null
Children:[StackPane@5483de69[styleClass=arrow]]
PARENT INFORMATION
Node:TreeViewSkin$1@269becf3[styleClass=cell indexed-cell tree-cell]'Item C' Class:class com.sun.javafx.scene.control.skin.TreeViewSkin$1 Id:null
Children:[Text[text="", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL_VERTICAL_CENTER, font=Font[name=System Regular, family=System, style=Regular, size=15.0], fontSmoothingType=LCD, fill=0x333333ff]]

at org.fxconnector.node.SVNodeFactory.createNode(SVNodeFactory.java:56)
at org.fxconnector.StageControllerImpl.createNode(StageControllerImpl.java:775)
at org.fxconnector.StageControllerImpl.lambda$new$10(StageControllerImpl.java:231)
at com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329)
at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
at javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:233)
at javafx.collections.FXCollections$UnmodifiableObservableListImpl.lambda$new$62(FXCollections.java:929)
at javafx.collections.WeakListChangeListener.onChanged(WeakListChangeListener.java:88)
at com.sun.javafx.collections.ListListenerHelper$SingleChange.fireValueChangedEvent(ListListenerHelper.java:164)
at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
at com.sun.javafx.collections.VetoableListDecorator.lambda$new$31(VetoableListDecorator.java:76)
at com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329)
at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
at javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:233)
at javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
at javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
at javafx.collections.ObservableListBase.endChange(ObservableListBase.java:205)
at javafx.collections.ModifiableObservableListBase.remove(ModifiableObservableListBase.java:183)
at com.sun.javafx.collections.VetoableListDecorator.remove(VetoableListDecorator.java:332)
at com.sun.javafx.collections.VetoableListDecorator.remove(VetoableListDecorator.java:221)
at javafx.scene.Parent.impl_toBack(Parent.java:644)
at javafx.scene.Node.toBack(Node.java:1756)
at com.sun.javafx.scene.control.skin.TreeCellSkin.updateDisclosureNode(TreeCellSkin.java:186)
at com.sun.javafx.scene.control.skin.TreeCellSkin.layoutChildren(TreeCellSkin.java:211)
at javafx.scene.control.Control.layoutChildren(Control.java:578)
at javafx.scene.Parent.layout(Parent.java:1087)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Scene.doLayoutPass(Scene.java:552)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2397)
at com.sun.javafx.tk.Toolkit.lambda$runPulse$29(Toolkit.java:398)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:397)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:424)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:518)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:498)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:491)
at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$403(QuantumToolkit.java:319)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)

最佳答案

我也遇到了这个,所以我会把@jimbo8 的评论作为答案:

这是由 ScenicView 引起的.

关闭 ScenicView,您将不会再收到此错误。

关于JavaFX TreeView java.lang.RuntimeException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49316378/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com