gpt4 book ai didi

警报(对话框)中的 JavaFX ConcurrentModificationException

转载 作者:行者123 更新时间:2023-12-01 10:10:26 28 4
gpt4 key购买 nike

在我的 JavaFX 应用程序中,我显示了一个确认对话框(该方法位于 MainController 类内部,并在主 JavaFX 线程上执行:

/**
* Shows a simple confirmation Dialog with ok/cancel button
*
* @param message the text inside the windows
* @return An The answer of the user
*/
private Optional<ButtonType> showConfirmDialog(String message) {
Alert alert = new Alert(AlertType.CONFIRMATION);
ButtonType buttonYes = new ButtonType(Messages.YES, ButtonData.YES);
ButtonType buttonNo = new ButtonType(Messages.CANCEL, ButtonData.CANCEL_CLOSE);
alert.getButtonTypes().setAll(buttonYes, buttonNo);

// make focuses button default button (-> which is fired when pressing enter)
Button noButton = (Button) alert.getDialogPane().lookupButton(buttonNo);
noButton.defaultButtonProperty().bind(noButton.focusedProperty());
Button yesButton = (Button) alert.getDialogPane().lookupButton(buttonYes);
yesButton.defaultButtonProperty().bind(yesButton.focusedProperty());

alert.setTitle(null);
alert.setHeaderText(message);
return alert.showAndWait(); // line 1260
}

请注意,我将默认按钮绑定(bind)到焦点按钮,如下所述:https://stackoverflow.com/a/29536464/1138523 。有一次,我收到以下 ConcurrentModificationException:

java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901) ~[?:1.8.0_51]
at java.util.ArrayList$Itr.next(ArrayList.java:851) ~[?:1.8.0_51]
at com.sun.javafx.tk.quantum.GlassStage.windowsSetEnabled(GlassStage.java:166) ~[jfxrt.jar:?]
at com.sun.javafx.tk.quantum.WindowStage.setVisible(WindowStage.java:441) ~[jfxrt.jar:?]
at javafx.stage.Window$9.invalidated(Window.java:860) ~[jfxrt.jar:?]
at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:109) ~[jfxrt.jar:?]
at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:144) ~[jfxrt.jar:?]
at javafx.stage.Window.setShowing(Window.java:910) ~[jfxrt.jar:?]
at javafx.stage.Window.hide(Window.java:935) ~[jfxrt.jar:?]
at javafx.scene.control.HeavyweightDialog.close(HeavyweightDialog.java:162) ~[jfxrt.jar:?]
at javafx.scene.control.Dialog.close(Dialog.java:383) ~[jfxrt.jar:?]
at javafx.scene.control.Dialog$2.invalidated(Dialog.java:631) ~[jfxrt.jar:?]
at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:111) ~[jfxrt.jar:?]
at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:146) ~[jfxrt.jar:?]
at javafx.scene.control.Dialog.setResult(Dialog.java:651) ~[jfxrt.jar:?]
at javafx.scene.control.Dialog.impl_setResultAndClose(Dialog.java:1001) ~[jfxrt.jar:?]
at javafx.scene.control.DialogPane.lambda$createButton$602(DialogPane.java:776) ~[jfxrt.jar:?]
at javafx.scene.control.DialogPane$$Lambda$367/203033415.handle(Unknown Source) ~[?:?]
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218) ~[jfxrt.jar:?]
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80) ~[jfxrt.jar:?]
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238) ~[jfxrt.jar:?]
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191) ~[jfxrt.jar:?]
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59) ~[jfxrt.jar:?]
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58) ~[jfxrt.jar:?]
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) ~[jfxrt.jar:?]
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) ~[jfxrt.jar:?]
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) ~[jfxrt.jar:?]
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) ~[jfxrt.jar:?]
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) ~[jfxrt.jar:?]
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) ~[jfxrt.jar:?]
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) ~[jfxrt.jar:?]
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74) ~[jfxrt.jar:?]
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49) ~[jfxrt.jar:?]
at javafx.event.Event.fireEvent(Event.java:198) ~[jfxrt.jar:?]
at javafx.scene.Node.fireEvent(Node.java:8390) ~[jfxrt.jar:?]
at javafx.scene.control.Button.fire(Button.java:185) ~[jfxrt.jar:?]
at com.sun.javafx.scene.control.skin.ButtonSkin.lambda$new$279(ButtonSkin.java:102) ~[jfxrt.jar:?]
at com.sun.javafx.scene.control.skin.ButtonSkin$$Lambda$199/1153218589.run(Unknown Source) ~[?:?]
at com.sun.javafx.scene.KeyboardShortcutsHandler.processAccelerators(KeyboardShortcutsHandler.java:347) ~[jfxrt.jar:?]
at com.sun.javafx.scene.KeyboardShortcutsHandler.dispatchBubblingEvent(KeyboardShortcutsHandler.java:163) ~[jfxrt.jar:?]
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59) ~[jfxrt.jar:?]
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58) ~[jfxrt.jar:?]
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) ~[jfxrt.jar:?]
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) ~[jfxrt.jar:?]
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) ~[jfxrt.jar:?]
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74) ~[jfxrt.jar:?]
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49) ~[jfxrt.jar:?]
at javafx.event.Event.fireEvent(Event.java:198) ~[jfxrt.jar:?]
at javafx.scene.Scene$KeyHandler.process(Scene.java:3965) ~[jfxrt.jar:?]
at javafx.scene.Scene$KeyHandler.access$1800(Scene.java:3911) ~[jfxrt.jar:?]
at javafx.scene.Scene.impl_processKeyEvent(Scene.java:2040) ~[jfxrt.jar:?]
at javafx.scene.Scene$ScenePeerListener.keyEvent(Scene.java:2502) ~[jfxrt.jar:?]
at com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:197) ~[jfxrt.jar:?]
at com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:147) ~[jfxrt.jar:?]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_51]
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleKeyEvent$349(GlassViewEventHandler.java:228) ~[jfxrt.jar:?]
at com.sun.javafx.tk.quantum.GlassViewEventHandler$$Lambda$347/1118191065.get(Unknown Source) ~[?:?]
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:404) ~[jfxrt.jar:?]
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(GlassViewEventHandler.java:227) ~[jfxrt.jar:?]
at com.sun.glass.ui.View.handleKeyEvent(View.java:546) ~[jfxrt.jar:?]
at com.sun.glass.ui.View.notifyKey(View.java:956) ~[jfxrt.jar:?]
at com.sun.glass.ui.win.WinApplication._enterNestedEventLoopImpl(Native Method) ~[jfxrt.jar:?]
at com.sun.glass.ui.win.WinApplication._enterNestedEventLoop(WinApplication.java:128) [jfxrt.jar:?]
at com.sun.glass.ui.Application.enterNestedEventLoop(Application.java:511) [jfxrt.jar:?]
at com.sun.glass.ui.EventLoop.enter(EventLoop.java:107) [jfxrt.jar:?]
at com.sun.javafx.tk.quantum.QuantumToolkit.enterNestedEventLoop(QuantumToolkit.java:593) [jfxrt.jar:?]
at javafx.stage.Stage.showAndWait(Stage.java:463) [jfxrt.jar:?]
at javafx.scene.control.HeavyweightDialog.showAndWait(HeavyweightDialog.java:157) [jfxrt.jar:?]
at javafx.scene.control.Dialog.showAndWait(Dialog.java:313) [jfxrt.jar:?]
at myApp.MainController.showConfirmDialog(MainController.java:1260) [bin/:?]

仅当我将焦点放在 ChoiceBox 上,然后显示确认对话框,然后按 CANCEL 按钮时,才会发生异常(exception)情况

有人知道问题出在哪里吗?也许问题是默认/聚焦按钮的绑定(bind)?

最佳答案

在比较堆栈跟踪时,它看起来可能是错误 JDK-8096583 : ConcurrentModificationException when closing APPLICATION_MODAL dialog 。根据错误报告,它已在 JDK 1.8.0u60 中修复。

关于警报(对话框)中的 JavaFX ConcurrentModificationException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36149316/

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