FXML中的JavaScript

我试图在MBean(JDK15 + OpenJFX15)的NetBeans上遵循this manual,但是在FXML上使用onaction="buttonClicked()时出现运行时错误:

控制台:

Caused by: javafx.fxml.LoadException: Error resolving onaction='buttonClicked()',either the event handler is not in the Namespace or there is an error in the script.
/C:/Proj/MAC/target/classes/com/deltav/mac/primary.fxml:21

FXML:

...
<? language javascript ?>
...

    <Button fx:id="mainButton" text="Click me!" onaction="buttonClicked()"/> <!-- line 21 -->
        <fx:script>
            function buttonClicked() {
                mainButton.setText("Click me again!")
            }
        </fx:script>   <!-- line 26 -->
        ...
    </Button>

    ...

如果删除onaction="buttonClicked()",我仍然会遇到运行时错误:

    at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: javafx.fxml.LoadException: Page language not specified.
/C:/Proj/MAC/target/classes/com/deltav/mac/primary.fxml:26

有什么问题吗?

zhangjuntu 回答:FXML中的JavaScript

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/1471916.html

大家都在问