The Visual Tool includes a TreeView with a graphic for each item. In recent SDKs, these graphics no longer appear. I have attempted to boil the problem down to this program:
import javafx.application.Application;
import javafx.builders.SceneBuilder;
import javafx.builders.StageBuilder;
import javafx.builders.VBoxBuilder;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
/**
* @author Eamonn McManus
*/
public class DeleteMe extends Application {
public static void main(String[] args) {
launch(args);
}
@Override public void start(Stage stage) throws Exception {
TreeItem<Label> root = new TreeItem<Label>(new Label("Root"));
TreeView<Label> tree = new TreeView<Label>(root);
Label label = new Label("Hello");
TreeItem<Label> item = new TreeItem<Label>(label);
String imageUrl = getClass().getClassLoader().getResource("javax/swing/plaf/basic/icons/JavaCup16.png").toString();
Image image = new Image(imageUrl);
ImageView imageView = new ImageView(image);
item.setGraphic(imageView);
root.getChildren().add(item);
VBox box = VBoxBuilder.create().children(tree).build();
Scene scene = SceneBuilder.create().height(200).width(200).root(box).build();
StageBuilder.create().scene(scene).visible(true).applyTo(stage);
}
}
I am not completely sure the program is correct but I think it is. There should be a coffee-cup icon beside the Hello label when you open the root node.
import javafx.application.Application;
import javafx.builders.SceneBuilder;
import javafx.builders.StageBuilder;
import javafx.builders.VBoxBuilder;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
/**
* @author Eamonn McManus
*/
public class DeleteMe extends Application {
public static void main(String[] args) {
launch(args);
}
@Override public void start(Stage stage) throws Exception {
TreeItem<Label> root = new TreeItem<Label>(new Label("Root"));
TreeView<Label> tree = new TreeView<Label>(root);
Label label = new Label("Hello");
TreeItem<Label> item = new TreeItem<Label>(label);
String imageUrl = getClass().getClassLoader().getResource("javax/swing/plaf/basic/icons/JavaCup16.png").toString();
Image image = new Image(imageUrl);
ImageView imageView = new ImageView(image);
item.setGraphic(imageView);
root.getChildren().add(item);
VBox box = VBoxBuilder.create().children(tree).build();
Scene scene = SceneBuilder.create().height(200).width(200).root(box).build();
StageBuilder.create().scene(scene).visible(true).applyTo(stage);
}
}
I am not completely sure the program is correct but I think it is. There should be a coffee-cup icon beside the Hello label when you open the root node.