简体   繁体   English

无法在javafx.scene.control.MenuItem中达到断点(JavaFX,Netbeans 8)

[英]Unable to reach Breakpoint in javafx.scene.control.MenuItem (JavaFX, Netbeans 8)

I'm trying to add a MenuBar to my JavaFX Project. 我正在尝试向我的JavaFX项目添加一个MenuBar。 Everything went well, until I added a second MenuItem to a Menu. 一切顺利,直到我在菜单中添加了第二个MenuItem。

...
    final Menu options = new Menu("Options");  // create the Menu

    final MenuItem settings1 = new MenuItem("Settings");  // create the first MenuItem
    settings1.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            Stage sSettings = new Stage();
            GridPane vGp = new GridPane();

            Button ok = new Button("Ok");
            ok.setOnAction(new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent event) {
                    ...
                    // CODE I NEED TO DEBUG
                    ...
                    sSettings.close();
                }

            });

            sSettings.setTitle("Settings");
            sSettings.setScene(new Scene(vGp, 800, 300));
            sSettings.show();
        }
    });
    options.getItems().add(settings1);

    final MenuItem settings2 = new MenuItem("Settings");  // create the second MenuItem
...

Now, if I add a second MenuItem the same way i created the MenuItem settings1 , everything would work fine. 现在,如果我以创建MenuItem settings1的相同方式添加第二个MenuItem,则一切正常。 The whole Code would be executed like I want it. 整个代码将按照我的意愿执行。

My Problem is the debugging of this Code. 我的问题是此代码的调试。 It is not possible to debug the Code, which will be executed, when clicked on the OK-Button of the opened Stage created by the second MenuItem. 单击第二个MenuItem创建的打开的舞台的“确定”按钮时,将无法调试将执行的代码。 The Code will be executed, but the Debugger won't stop inside the definition. 代码将被执行,但是调试器不会在定义内停止。

My only option is to comment every single MenuItem defined before the MenuItem I want to work on. 我唯一的选择是注释要在MenuItem之前定义的每个MenuItem。 And I think it's going to be annoying very fast. 而且我认为这会非常烦人。

Anyone else got the same Problem? 还有其他人遇到同样的问题吗? Maybe its IDE specific: 也许是特定于IDE的:

I'm using Netbeans 8.0.1 with jdk1.8.0_11 on Linux. 我在Linux上将Netbeans 8.0.1与jdk1.8.0_11结合使用。 Code Example: https://gist.github.com/mul8or/8b94e440eda49b2d8fed 代码示例: https//gist.github.com/mul8or/8b94e440eda49b2d8fed

I managed to debug the code inside the OK-Button perfectly fine in Netbeans same environment as you in Windows. 在与Windows中相同的Netbeans环境中,我设法调试了OK-Button内的代码。 I set the breakpoint at 我将断点设置为

sSettings.close();

and the debugger stop at the breakpoint perfectly fine. 并且调试器在断点处完全停止。 It might be due to some condition specified in other parts of your code or you attach the wrong button? 这可能是由于代码其他部分中指定的某些条件引起的,还是您附加了错误的按钮?

I've also managed to debug this code perfectly fine in IntelliJ IDEA 13.1. 我还设法在IntelliJ IDEA 13.1中完美调试了此代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM