0

I got the source code for solving rubik's cube in javaFX from here. There's a code for prompting dialog for user input or for confirmation as:

Button bSeq = new Button("Sequence");
    bSeq.setOnAction(e -> {
        String response;
        if (moves.getNumMoves() > 0) {
            response = 
                    Dialogs.create()
                    .owner(stage)
                    .title("Warning Dialog")
                    .masthead("Loading a Sequence").lightweight()
                    .message("Add a valid sequence of movements:\n(previous movements will be discarded)")
                    .showTextInput(moves.getSequence());
        } else {
            response = Dialogs.create()
                    .owner(stage)
                    .title("Information Dialog")
                    .masthead("Loading a Sequence").lightweight()
                    .message("Add a valid sequence of movements")
                    .showTextInput();
        }
        System.out.println("r: " + response);
        if (response != null && !response.isEmpty()) {
            rubik.doReset();
            rubik.doSequence(response.trim());
        }
    });

and for confirmation dialog:

Button bSc = new Button("Scramble");
    bSc.setOnAction(e -> {
        if (moves.getNumMoves() > 0) {
            Action response = Dialogs.create()
                    .owner(stage)
                    .title("Warning Dialog")
                    .masthead("Scramble Cube")
                    .message("You will lose all your previous movements. Do you want to continue?")
                    .showConfirm();
            if (response == Dialog.Actions.YES) {
                rubik.doReset();
                doScramble();
            }
        } else {
            doScramble();
        }
    });

But on clicking that bSeq and bSc button no dialog is getting prompt and the exception I am getting is:

java.lang.NoSuchMethodError: com.sun.javafx.scene.traversal.TraversalEngine.<init>(Ljavafx/scene/Parent;Z)V
    at org.controlsfx.control.ButtonBar$2.<init>(ButtonBar.java:413)
    at org.controlsfx.control.ButtonBar.<init>(ButtonBar.java:413)
    at org.controlsfx.control.ButtonBar.<init>(ButtonBar.java:356)
    at org.controlsfx.dialog.Dialog.createButtonPanel(Dialog.java:978)
    at org.controlsfx.dialog.Dialog.createCenterPanel(Dialog.java:973)
    at org.controlsfx.dialog.Dialog.buildDialogContent(Dialog.java:894)
    at org.controlsfx.dialog.Dialog.show(Dialog.java:321)
    at org.controlsfx.dialog.Dialogs.showTextInput(Dialogs.java:537)
    at org.controlsfx.dialog.Dialogs.showTextInput(Dialogs.java:545)
    at com.jpl.games.RubikFX.lambda$start$5(RubikFX.java:125)
    at com.jpl.games.RubikFX$$Lambda$95/2071613919.handle(Unknown Source)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
r: null
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
    at javafx.event.Event.fireEvent(Event.java:198)
    at javafx.scene.Node.fireEvent(Node.java:8390)
    at javafx.scene.control.Button.fire(Button.java:185)
    at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
    at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.event.Event.fireEvent(Event.java:198)
    at javafx.scene.Scene$MouseHandler.process(Scene.java:3758)
    at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3486)
    at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
    at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2495)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:350)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:275)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$350(GlassViewEventHandler.java:385)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$$Lambda$165/13695958.get(Unknown Source)
    at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:404)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:384)
    at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
    at com.sun.glass.ui.View.notifyMouse(View.java:927)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$145(WinApplication.java:101)
    at com.sun.glass.ui.win.WinApplication$$Lambda$36/1963387170.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)

If i remove that Diaog.create() and enter response manually, everything works fine.

1 Answers1

1

You have not told us which JDK and ControlsFX version you are using but I'd guess that you are hit by this issue.

http://fxexperience.com/2015/08/controlsfx-and-javafx-8u60/

By the way, the current snapshot link is now

https://oss.sonatype.org/content/repositories/snapshots/org/controlsfx/controlsfx/8.40.11-SNAPSHOT/

You might also try to convert the code to standard JavaFX dialogs which are available for some time now.

mipa
  • 10,369
  • 2
  • 16
  • 35
  • jdk 1.8 and controlsfx-8.0.5.jar – Mishra Shreyanshu Nov 01 '15 at 16:19
  • This is not enough information. Which update of jdk 1.8? If it is the latest 8u66 then your controlsfx version is far too old. – mipa Nov 01 '15 at 18:35
  • Ok, and did you then follow the advice to update your controlsfx library to 8.40.11? – mipa Nov 02 '15 at 21:25
  • Yes I did but when I am importing `import org.controlsfx.control.action.Action;` , I am getting error package org.controlsfx.control.action does not exist. – Mishra Shreyanshu Nov 04 '15 at 05:24
  • Then there is something wrong with your classpath. I just gave it a try with controlsfx-8.40.11-20151101.010657-44.jar and the above mentioned path is definitely contained in this jar file. – mipa Nov 04 '15 at 14:42