fmxl Missing handler script

错误的fmxl文件写法:

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>

<VBox alignment="TOP_CENTER" minWidth="158.0" prefHeight="710.0" prefWidth="158.0" xmlns:fx="http://javafx.com/fxml" fx:controller="testFXML.CustomControl">
  <children>
    <Button mnemonicParsing="false" onAction="" prefWidth="150.0" text="新预订" VBox.vgrow="ALWAYS">
      <VBox.margin>
        <Insets bottom="5.0" left="5.0" right="5.0" />
      </VBox.margin>
    </Button>
    <Button mnemonicParsing="false" onAction="" prefWidth="150.0" text="修改预订" VBox.vgrow="ALWAYS">
      <VBox.margin>
        <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" fx:id="x1" />
      </VBox.margin>
    </Button>
    <Button mnemonicParsing="false" onAction="" prefWidth="150.0" text="取消预订" VBox.margin="$x1" VBox.vgrow="ALWAYS" />
    <Button mnemonicParsing="false" onAction="" prefWidth="150.0" text="预订金处理" VBox.margin="$x1" VBox.vgrow="ALWAYS" />
    <Button mnemonicParsing="false" onAction="" prefWidth="150.0" text="预订入住" VBox.margin="$x1" VBox.vgrow="ALWAYS" />
    <Button mnemonicParsing="false" onAction="" prefWidth="150.0" text="刷新" VBox.margin="$x1" VBox.vgrow="ALWAYS" />
    <Button mnemonicParsing="false" onAction="" prefWidth="150.0" text="打印" VBox.margin="$x1" VBox.vgrow="ALWAYS" />
    <TitledPane animated="false" collapsible="false" expanded="true" minWidth="150.0" prefHeight="91.0" prefWidth="150.0" text="姓名/电话" underline="false">
      <content>
        <VBox prefHeight="19.0" prefWidth="162.0">
          <children>
            <TextField prefWidth="200.0" text="5555" />
          </children>
        </VBox>
      </content>
      <VBox.margin>
        <Insets bottom="5.0" left="10.0" right="10.0" top="462.0" />
      </VBox.margin>
    </TitledPane>
  </children>
</VBox>
注意上面的onAction=""

如果在程序中加载运行的话,会报如下的错误:

Missing handler script.
/C:/Users/Administrator/git/testjavafx/bin/testFXML/testFXML.fxml:12
  at javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(FXMLLoader.java:501)
  at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:589)
  at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2430)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2136)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2744)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2723)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2709)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2696)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2685)
  at testFXML.CustomControlExample.start(CustomControlExample.java:15)
  at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
  at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:215)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
  at java.security.AccessController.doPrivileged(Native Method)
  at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
  at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
  at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
  at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
  at java.lang.Thread.run(Unknown Source)


Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403)
at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
at java.lang.Thread.run(Unknown Source)
Caused by: javafx.fxml.LoadException: Missing handler script.
at javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(FXMLLoader.java:501)
at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:589)
at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2430)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2136)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2744)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2723)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2709)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2696)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2685)
at testFXML.CustomControlExample.start(CustomControlExample.java:15)
at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:215)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
... 1 more

改成如下的形式:

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>

<VBox alignment="TOP_CENTER" minWidth="158.0" prefHeight="710.0" prefWidth="158.0" xmlns:fx="http://javafx.com/fxml" fx:controller="testFXML.CustomControl">
  <children>
    <Button mnemonicParsing="false" prefWidth="150.0" text="新预订" VBox.vgrow="ALWAYS">
      <VBox.margin>
        <Insets bottom="5.0" left="5.0" right="5.0" />
      </VBox.margin>
    </Button>
    <Button mnemonicParsing="false"  prefWidth="150.0" text="修改预订" VBox.vgrow="ALWAYS">
      <VBox.margin>
        <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" fx:id="x1" />
      </VBox.margin>
    </Button>
    <Button mnemonicParsing="false"  prefWidth="150.0" text="取消预订" VBox.margin="$x1" VBox.vgrow="ALWAYS" />
    <Button mnemonicParsing="false"  prefWidth="150.0" text="预订金处理" VBox.margin="$x1" VBox.vgrow="ALWAYS" />
    <Button mnemonicParsing="false"  prefWidth="150.0" text="预订入住" VBox.margin="$x1" VBox.vgrow="ALWAYS" />
    <Button mnemonicParsing="false"  prefWidth="150.0" text="刷新" VBox.margin="$x1" VBox.vgrow="ALWAYS" />
    <Button mnemonicParsing="false"  prefWidth="150.0" text="打印" VBox.margin="$x1" VBox.vgrow="ALWAYS" />
    <TitledPane animated="false" collapsible="false" expanded="true" minWidth="150.0" prefHeight="91.0" prefWidth="150.0" text="姓名/电话" underline="false">
      <content>
        <VBox prefHeight="19.0" prefWidth="162.0">
          <children>
            <TextField prefWidth="200.0" text="5555" />
          </children>
        </VBox>
      </content>
      <VBox.margin>
        <Insets bottom="5.0" left="10.0" right="10.0" top="462.0" />
      </VBox.margin>
    </TitledPane>
  </children>
</VBox>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值