我已经玩摇摆了一段时间,现在决定退房。到目前为止,我发现与摇摆相比,使用起来更轻松,更有趣,但是我遇到了一个小的减速带,经过几个小时的环顾四周,我无法找到解决方案
当我尝试通过fxml文件添加它时,我无法使用\ u 如果我不使用fxml但我想使用场景构建器,它可以正常工作更方便。 这是一小段代码:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.131" fx:controller="baitform.designDocController">
<children>
<Button fx:id="button" layoutX="126" layoutY="90" onAction="#handleButtonAction" text="Click Me!" />
<Label layoutX="145.0" layoutY="129.0" text="\u0644\u0627\u062B\u0627\u0646\u0649" />
</children>
</AnchorPane>
我一直得到的错误是
引起:javafx.fxml.LoadException:转义序列无效。
不确定是否相关,但我使用 jdk1.8.0_131 &amp; netbeans 8.2
如果有人能指出我在正确的方向,我真的很感激。
答案 0 :(得分:2)
FXML是一种XML,因此您需要使用XML转义:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.131" fx:controller="baitform.designDocController">
<children>
<Button fx:id="button" layoutX="126" layoutY="90" onAction="#handleButtonAction" text="Click Me!" />
<Label layoutX="145.0" layoutY="129.0" text="لاثانى" />
</children>
</AnchorPane>
话虽这么说,如果你能输入字符,你可以按原样插入它们。