Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当我尝试初始化CategoryAxis xAxis时,我得到java.lang.ExceptionInInitializeError_Java_Swing_Jpanel - Fatal编程技术网

当我尝试初始化CategoryAxis xAxis时,我得到java.lang.ExceptionInInitializeError

当我尝试初始化CategoryAxis xAxis时,我得到java.lang.ExceptionInInitializeError,java,swing,jpanel,Java,Swing,Jpanel,我试图将条形图添加到现有的jPanel中,但出现以下错误: Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError at javafx.scene.chart.Axis.<init>(Axis.java:85) at javafx.scene.chart.CategoryAxis.<init>(CategoryAxis.java:251) at Gui.MainFrame.S

我试图将条形图添加到现有的jPanel中,但出现以下错误:

Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError
at javafx.scene.chart.Axis.<init>(Axis.java:85)
at javafx.scene.chart.CategoryAxis.<init>(CategoryAxis.java:251)
at Gui.MainFrame.SetJFX(MainFrame.java:521)
at Gui.MainFrame.SetResTable(MainFrame.java:516)
at Gui.MainFrame.ExecuteButtonActionPerformed(MainFrame.java:490)
at Gui.MainFrame.access$200(MainFrame.java:49)
at Gui.MainFrame$3.actionPerformed(MainFrame.java:171)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2739)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:746)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:697)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:719)
at java.awt.EventQueue$4.run(EventQueue.java:717)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:716)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.IllegalStateException: Toolkit not initialized
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:270)
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:265)
at com.sun.javafx.application.PlatformImpl.setPlatformUserAgentStylesheet(PlatformImpl.java:540)
at com.sun.javafx.application.PlatformImpl.setDefaultPlatformUserAgentStylesheet(PlatformImpl.java:502)
at javafx.scene.control.Control.<clinit>(Control.java:87)
... 43 more
线程“AWT-EventQueue-0”java.lang.ExceptionInInitializeError中的异常 位于javafx.scene.chart.Axis(Axis.java:85) 位于javafx.scene.chart.CategoryAxis。(CategoryAxis.java:251) 位于Gui.MainFrame.SetJFX(MainFrame.java:521) 位于Gui.MainFrame.SetResTable(MainFrame.java:516) 在Gui.MainFrame.ExecuteButtonActionPerformed处(MainFrame.java:490) 在Gui.MainFrame.access$200(MainFrame.java:49) 在Gui.MainFrame$3.actionPerformed(MainFrame.java:171) 在javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022) 位于javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346) 在javax.swing.DefaultButtonModel.fireActionPerformed上(DefaultButtonModel.java:402) 在javax.swing.DefaultButtonModel.setPressed中(DefaultButtonModel.java:259) 在javax.swing.plaf.basic.BasicButtonListener.MouseRelease(BasicButtonListener.java:252) 位于java.awt.Component.ProcessMouseeEvent(Component.java:6525) 位于javax.swing.JComponent.ProcessMouseeEvent(JComponent.java:3321) 位于java.awt.Component.processEvent(Component.java:6290) 位于java.awt.Container.processEvent(Container.java:2234) 位于java.awt.Component.dispatchEventImpl(Component.java:4881) 位于java.awt.Container.dispatchEventImpl(Container.java:2292) 位于java.awt.Component.dispatchEvent(Component.java:4703) 位于java.awt.LightweightDispatcher.RetargetMouseeEvent(Container.java:4898) 位于java.awt.LightweightDispatcher.ProcessMouseeEvent(Container.java:4533) 位于java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462) 位于java.awt.Container.dispatchEventImpl(Container.java:2278) 位于java.awt.Window.dispatchEventImpl(Window.java:2739) 位于java.awt.Component.dispatchEvent(Component.java:4703) 位于java.awt.EventQueue.dispatchEventImpl(EventQueue.java:746) 在java.awt.EventQueue.access$400(EventQueue.java:97) 位于java.awt.EventQueue$3.run(EventQueue.java:697) 位于java.awt.EventQueue$3.run(EventQueue.java:691) 位于java.security.AccessController.doPrivileged(本机方法) 位于java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75) 位于java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86) 在java.awt.EventQueue$4.run(EventQueue.java:719) 在java.awt.EventQueue$4.run(EventQueue.java:717) 位于java.security.AccessController.doPrivileged(本机方法) 位于java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75) 位于java.awt.EventQueue.dispatchEvent(EventQueue.java:716) 位于java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) 在java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)中 位于java.awt.EventDispatchThread.PumpeEventsforHierarchy(EventDispatchThread.java:105) 位于java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) 位于java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) 在java.awt.EventDispatchThread.run(EventDispatchThread.java:82) 原因:java.lang.IllegalStateException:工具箱未初始化 位于com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:270) 位于com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:265) 位于com.sun.javafx.application.PlatformImpl.setPlatformUserAgentStylesheet(PlatformImpl.java:540) 位于com.sun.javafx.application.PlatformImpl.setDefaultPlatformUserAgentStylesheet(PlatformImpl.java:502) 位于javafx.scene.control.control.(control.java:87) ... 43多 我不确定发生了什么,但我认为问题的原因是我试图向jpanel添加JFXpanel

 521-->CategoryAxis xAxis = new CategoryAxis();
    NumberAxis yAxis = new NumberAxis();

    xAxis.setLabel("Threads");
    yAxis.setLabel("Time to msec");

    BarChart<String, Number> BC = new BarChart<String, Number>(xAxis, yAxis);
    BC.setTitle("Time-Threads Compare");

    XYChart.Series series = new XYChart.Series();

    for (int i = 0; i < ThreadsNumOptions.size(); i++) {
        for (int j = 0; j < Results.size(); j++) {
            long sum = 0;
            long times = 0;

            if (ThreadsNumOptions.get(i).equals(Results.get(j).getMaxThreads())) {
                times++;
                sum += Results.get(j).getRawTime();
            }

            if(times>0){
                series.getData().add(new XYChart.Data(ThreadsNumOptions.get(i)+" thread(s)",new TimeKeeper().GetTime((int) (sum/times))));
            }
        }
    }

    Scene scene  = new Scene(BC,300,225);
    BC.getData().add(series);

    final JFXPanel fxPanel = new JFXPanel();
    fxPanel.setScene(scene);

    jPanelFX.add(fxPanel);
521-->CategoryAxis xAxis=新CategoryAxis();
NumberAxis yAxis=新的NumberAxis();
xAxis.setLabel(“线程”);
yAxis.setLabel(“到毫秒的时间”);
条形图BC=新条形图(xAxis,yAxis);
BC.setTitle(“时间线程比较”);
XYChart.Series系列=新的XYChart.Series();
对于(int i=0;i0){
series.getData().add(新的XYChart.Data(ThreadsNumOptions.get(i)+“thread(s)”,新的TimeKeeper().GetTime((int)(sum/times)));
}
}
}
场景=新场景(BC,300225);
BC.getData().add(系列);
最终JFXPanel fxPanel=新JFXPanel();
fxPanel.setScene(场景);
jPanelFX.add(fxPanel);
理想情况下,你应该发布一篇文章


如果没有看到此源代码,我无法确定,但它看起来非常像您试图在AWT线程中初始化JavaFX GUI组件。

在Post中发布完整的stacktrace。类似问题: