Javafx 标记上的FXML HBox.hgrow属性失败,出现枚举错误
我正在尝试将一些工作的JavaFX代码转换为FXML。我尝试了以下操作,但出现错误: java.lang.IllegalArgumentException:无枚举常量javafx.scene.layout.Priority.AlwaysJavafx 标记上的FXML HBox.hgrow属性失败,出现枚举错误,javafx,Javafx,我正在尝试将一些工作的JavaFX代码转换为FXML。我尝试了以下操作,但出现错误: java.lang.IllegalArgumentException:无枚举常量javafx.scene.layout.Priority.Always 然后我尝试了一种不同的方法,这是可行的,但是我不明白为什么第一种方法不行,而第二种方法不行。我在这里看到了第一种方式的代码示例,是否有什么变化,代码示例是否太旧,是否缺少一些导入,或者是否完全无法理解我在做什么 <?import javafx.scen
然后我尝试了一种不同的方法,这是可行的,但是我不明白为什么第一种方法不行,而第二种方法不行。我在这里看到了第一种方式的代码示例,是否有什么变化,代码示例是否太旧,是否缺少一些导入,或者是否完全无法理解我在做什么
<?import javafx.scene.layout.VBox ?>
<?import javafx.scene.layout.HBox ?>
<?import javafx.scene.layout.Pane ?>
<?import javafx.scene.layout.Priority ?>
<VBox xmlns:fx="http://javafx.com/fxml" >
<HBox>
<Button text="License" />
<Button text="Credits" />
<Pane>
<HBox.hgrow><Priority fx:value="ALWAYS" /></HBox.hgrow>
</Pane>
<Button text="Exit" />
</HBox>
</VBox>
上面的James_D知道了,结果发现我打错了。有时额外的眼睛会捕捉到愚蠢 改变
到
如果您将其更改为
?@James\u D,则它不起作用,很可能就是它。我喜欢打字错误,用吧。
<?import javafx.scene.layout.VBox ?>
<?import javafx.scene.layout.HBox ?>
<?import javafx.scene.layout.Pane ?>
<?import javafx.scene.layout.Priority ?>
<VBox xmlns:fx="http://javafx.com/fxml" >
<HBox>
<Button text="License" />
<Button text="Credits" />
<Pane>
<HBox.hgrow><Priority fx:value="ALWAYS" /></HBox.hgrow>
</Pane>
<Button text="Exit" />
</HBox>
</VBox>
<Pane>
<HBox.hgrow><Priority fx:value="ALWAYS" /></HBox.hgrow>
</Pane>
<Pane HBox.hgrow="ALWAYS"></Pane>