电话错误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>
文章结束给大家分享下程序员的一些笑话语录: 苹果与谷歌之争就是封闭收费与自由免费思想之争。(别急着把google来膜拜哦?那可是一家公司,以赚钱为目标的公司!当年我Party就是这样把广大劳动人民吸引过来的。今天的结果你们都看到了。)