FXML 代码 -
<TreeItem expanded="true" value="1">
<graphic>
<ImageView fx:id="folderImageView"/>
</graphic>
<children>
<TreeItem value="11" />
</children>
</TreeItem>
<TreeItem expanded="true" value="2">
<graphic>
<ImageView fx:id="folderImageView"/>
</graphic>
<children>
<TreeItem value="2" />
</children>
</TreeItem>
这是控制器代码 -
public class LController implements Initializable {
@FXML ImageView folderImageView;
public void initialize(URL location, ResourceBundle resources) {
folderImageView.setImage(new Image("/resource/b.png"));
}
图片 b.png 仅在最后一个 TreeItem 中显示(即 value=2)
你能建议吗?