Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8115941

Graphics in TreeItems no longer appear

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: fx2.0
    • Fix Version/s: fx2.0
    • Component/s: javafx
    • Labels:

      Description

      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.

        Attachments

          Activity

            People

            Assignee:
            jgiles Jonathan Giles
            Reporter:
            emcmanuswse Eamonn McManus (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: