以下の fxml から FXMLLoader.load(...) で構築.
<ScrollPane fx:id="fxsource_pane" id="source_pane" fitToHeight="true" fitToWidth="true" prefHeight="511.0" prefWidth="600.0" BorderPane.alignment="CENTER">
<content>
<TextArea fx:id="source_text" prefHeight="200.0" prefWidth="200.0">
<font>
<Font name="SansSerif Regular" size="12.0" />
</font>
</TextArea>
</content>
</ScrollPane>
ここから、getId() でどちらが返されるのか.
ScrollPane sp = FXMLLoader.load(getClass().getResource("SimpleTextView.fxml"));
System.out.println("getId() returned: " + sp.getId());
結果:
>getId() returned source_pane
NOTE:
fx:id のみ定義した場合 fx:id の値が返される.
両方定義した場合 id の値が返される.
javadoc からの引用
This is analogous to the "id" attribute on an HTML element