2

I get an exception from my costum dialog right at the moment when I click the close button.

Exception in thread "JavaFX Application Thread" java.lang.IllegalStateException: Nested event loops are allowed only while handling system events
    at com.sun.javafx.tk.quantum.QuantumToolkit.enterNestedEventLoop(Unknown Source)
    at javafx.stage.Stage.showAndWait(Unknown Source)
    at javafx.scene.control.HeavyweightDialog.showAndWait(Unknown Source)
    at javafx.scene.control.Dialog.showAndWait(Unknown Source)
    at puni.view.CustomDialog.showReport(CustomDialog.java:251)
    at puni.view.OverviewController.showReportDialog(OverviewController.java:1088)
    at puni.view.OverviewController.startOverview(OverviewController.java:1136)
    at puni.view.OverviewController.access$0(OverviewController.java:1095)
    at puni.view.OverviewController$3.handle(OverviewController.java:538)
    at puni.view.OverviewController$3.handle(OverviewController.java:1)
    at javafx.animation.Animation.impl_finished(Unknown Source)
    at javafx.animation.AnimationAccessorImpl.finished(Unknown Source)
    at com.sun.scenario.animation.shared.SingleLoopClipEnvelope.timePulse(Unknown Source)
    at javafx.animation.Animation.impl_timePulse(Unknown Source)
    at javafx.animation.Animation$1.lambda$timePulse$26(Unknown Source)
    at javafx.animation.Animation$1$$Lambda$246/14625425.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at javafx.animation.Animation$1.timePulse(Unknown Source)
    at com.sun.scenario.animation.AbstractMasterTimer.timePulseImpl(Unknown Source)
    at com.sun.scenario.animation.AbstractMasterTimer$MainLoop.run(Unknown Source)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(Unknown Source)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(Unknown Source)
    at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$400(Unknown Source)
    at com.sun.javafx.tk.quantum.QuantumToolkit$$Lambda$40/6985548.run(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$145(Unknown Source)
    at com.sun.glass.ui.win.WinApplication$$Lambda$36/3326003.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)


Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: Key not associated with a running event loop: javafx.scene.control.HeavyweightDialog$1@1a9ed1e
    at com.sun.javafx.tk.quantum.QuantumToolkit.exitNestedEventLoop(Unknown Source)
    at javafx.stage.Stage.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.scene.control.HeavyweightDialog.close(Unknown Source)
    at javafx.scene.control.Dialog.close(Unknown Source)
    at puni.view.CustomDialog$1.handle(CustomDialog.java:222)
    at puni.view.CustomDialog$1.handle(CustomDialog.java:1)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
    at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
    at javafx.event.Event.fireEvent(Unknown Source)
    at javafx.scene.Node.fireEvent(Unknown Source)
    at javafx.scene.control.Button.fire(Unknown Source)
    at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(Unknown Source)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source)
    at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(Unknown Source)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
    at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
    at javafx.event.Event.fireEvent(Unknown Source)
    at javafx.scene.Scene$MouseHandler.process(Unknown Source)
    at javafx.scene.Scene$MouseHandler.access$1500(Unknown Source)
    at javafx.scene.Scene.impl_processMouseEvent(Unknown Source)
    at javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$350(Unknown Source)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$$Lambda$258/29661310.get(Unknown Source)
    at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(Unknown Source)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
    at com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
    at com.sun.glass.ui.View.notifyMouse(Unknown Source)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$145(Unknown Source)
    at com.sun.glass.ui.win.WinApplication$$Lambda$36/3326003.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Uluk Biy
  • 48,655
  • 13
  • 146
  • 153
Punika
  • 354
  • 3
  • 16

2 Answers2

3

I solved the issue by using Platform.runLater();

Platform.runLater(new Runnable(){
    @Override
    public void run() {
        dialog.showAndWait();               
    }           
});

This works but is that a good solution and what is the background of the exception?

Punika
  • 354
  • 3
  • 16
  • hmm .. sounds like a hack (which might bite you in future, as all hacks do ;-) Helping you to dig to the bottom of the problem requires a SSCCE that demonstrates the problem. – kleopatra Aug 06 '15 at 08:32
  • Your are right. Do you mean I should post the affected code or what does SSCCE mean ^^ – Punika Aug 07 '15 at 08:52
  • 1
    well, you do have access to a search machine, don't you ;-) Also, don't forget to read the help topic of this site about how to ask for maximum help (the acronym - MVCE (?) - is different, but meaning the same) – kleopatra Aug 07 '15 at 09:31
0

I'm not an JavaFX expert, so this is mostly guessing:

The use of runLater() takes the action out of the event loop of the dialog window and moves it onto the main event loop of the application. This might prevent further nesting which seems to cause the problem.

The lack of information or code makes this kinda hard to understand.

pschichtel
  • 759
  • 7
  • 18