使用JavaFX控件时“JavaFX Application Thread”中的异常

时间:2014-05-01 21:12:06

标签: java swing javafx-8 pane

我正在使用枚举值初始化通用JavaFX 8 ComboBox,如下所示:

ObservableList<MyEnumClass> myValues = FXCollections
        .observableArrayList(MyEnumClass.FIRST_ENUM, 
                MyEnumClass.SECOND_ENUM, MyEnumClass.THIRD_ENUM);
myEnumComboBox = new ComboBox<MyEnumClass>(myValues);     

测试应用程序按预期显示具有Enum值的ComboBox,并且选择其他值也可以正常工作。但有一件事让我感到困惑:尽管我无法观察到任何明显的故障,但每当我从ComboBox菜单中选择一个新值时,我的Eclipse控制台仍会通知线程“JavaFX Application Thread”中的异常。该异常似乎与隐藏ComboBox弹出控件的本机JavaFX代码有关:

Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: null source
    at java.util.EventObject.<init>(Unknown Source)
    at java.awt.AWTEvent.<init>(Unknown Source)
    at sun.awt.UngrabEvent.<init>(Unknown Source)
    at javafx.embed.swing.SwingNode$10.handle(Unknown Source)
        [9 lines omitted]
    at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
    at javafx.event.Event.fireEvent(Unknown Source)
    at com.sun.javafx.stage.WindowPeerListener.focusUngrab(Unknown Source)
        [4 lines omitted]
    at com.sun.glass.ui.Window.handleWindowEvent(Unknown Source)
    at com.sun.glass.ui.Window.notifyFocusUngrab(Unknown Source)
    at com.sun.glass.ui.win.WinWindow._ungrabFocus(Native Method)
    at com.sun.glass.ui.Window.ungrabFocus(Unknown Source)
    at com.sun.javafx.tk.quantum.WindowStage.ungrabFocus(Unknown Source)
    at javafx.stage.Window.decreaseFocusGrabCounter(Unknown Source)
    at javafx.stage.PopupWindow.handleAutohideActivation(Unknown Source)
    at javafx.stage.PopupWindow.impl_visibleChanged(Unknown Source)
    at javafx.stage.Window$9.invalidated(Unknown Source)
    at javafx.beans.property.BooleanPropertyBase.markInvalid(Unknown Source)
    at javafx.beans.property.BooleanPropertyBase.set(Unknown Source)
    at javafx.stage.Window.setShowing(Unknown Source)
    at javafx.stage.Window.hide(Unknown Source)
    at javafx.stage.PopupWindow.hide(Unknown Source)
    at com.sun.javafx.scene.control.skin.ComboBoxPopupControl.hide(Unknown Source)
        [44 lines omitted]
    at java.lang.Thread.run(Unknown Source)

有人可以解释一下这里究竟发生了什么以及我能做些什么或应该做些什么?


编辑 - 异常是由与早期实验相同的Pane中的剩余SwingNode引起的。删除SwingNode使异常消失。

0 个答案:

没有答案