我已经玩了一段时间的 swing,现在决定看看 FX。到目前为止,我发现与 swing 相比,它更容易、更有趣,但我遇到了一个小减速带,经过几个小时的环顾,我只是找不到解决方案。
当我尝试通过 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 & 网豆 8.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>
话虽如此,如果您能够输入字符,则可以按原样插入它们。
也可以看看:https://www.w3.org/International/questions/qa-escapes
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)