2017-08-16 1 views
0

J'ai une TextField et une étiquette avec mnemonicParsing vrai. Je veux définir la propriété labelFor du label avec l'id du TextField. Comment je fais ça en FXML?JavaFx: Comment définir la propriété labelFor d'un Label en FXML?

<GridPane hgap="5.0" snapToPixel="false" vgap="10.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> 
<children> 
     <Label maxWidth="-Infinity" text="_A Label" GridPane.halignment="RIGHT" GridPane.hgrow="NEVER" GridPane.vgrow="NEVER" mnemonicParsing="true" /> 
     <TextField id="myTextField" GridPane.columnIndex="1" GridPane.hgrow="NEVER" /> 
</children> 
</GridPane> 

Merci

Répondre

0

Si trouvé la solution ...

<GridPane hgap="5.0" snapToPixel="false" vgap="10.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> 
<children> 
     <Label maxWidth="-Infinity" text="_A Label" GridPane.halignment="RIGHT" GridPane.hgrow="NEVER" GridPane.vgrow="NEVER" mnemonicParsing="true"> 
      <labelFor> 
       <TextField id="myTextField" GridPane.columnIndex="1" GridPane.hgrow="NEVER" /> 
      </labelFor> 
     </Label> 
     <fx:reference source="myTextField" /> 
</children> 
</GridPane> 
0

Vous pouvez utiliser la notation du dollar:

<GridPane hgap="5.0" snapToPixel="false" vgap="10.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> 
    <children> 
      <Label labelFor="$myTextField" maxWidth="-Infinity" text="_A Label" GridPane.halignment="RIGHT" GridPane.hgrow="NEVER" GridPane.vgrow="NEVER" mnemonicParsing="true" /> 
      <TextField id="myTextField" GridPane.columnIndex="1" GridPane.hgrow="NEVER" /> 
    </children> 
</GridPane>