如何将其移至FXML?
hBox.getProperties().put("key", "value");
答案 0 :(得分:5)
你可以做到
<HBox>
<properties key="value"/>
</HBox>
变化
<HBox>
<properties>
<key>
<String fx:value="value"/>
</key>
</properties>
</HBox>
如果您想要的值是更复杂的对象,可能很有用:
<HBox>
<properties>
<character>
<String fx:value="Arthur Dent"/>
</character>
<actor>
<Actor firstName="Simon" lastName="Jones"/>
</actor>
<properties>
</HBox>
相当于
Actor actor = new Actor();
actor.setFirstName("Simon");
actor.setLastName("Jones");
HBox hbox = new HBox();
hbox.getProperties().put("character", "Arthur Dent");
hbox.getProperties().put("actor", actor);