2015-09-02 212 views

回答

4

你可以做

<HBox> 
    <properties key="value"/> 
</HBox> 

documentation

變化

<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); 
+0

感謝您的解釋!谷歌沒有幫助我,但你確實很棒! – Jerry0022