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

ImageView doesn't load Image from style sheet (still)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • fx2.0
    • fx2.0
    • javafx
    • Windows 7, b42

      Issue RT-14027 (http://javafx-jira.kenai.com/browse/RT-14027) is marked as Resolved, however in Build 42 I am seeing the behaviour of the original poster.

      My classpath directory structure looks like this:

      /stylesheet.css
      /images/my-image.png
      /com/zonski/jfx/TestApplication.class

      stylesheet.css:

        .imageView {
            -fx-image: url("images/my-image.png");
            -fx-cursor: hand;
        }

      TestApplication.java:

        public class TestApplication extends Application
        {
          public static void main(String[] args)
          {
              Application.launch(TestApplication.class, args);
          }

          public void start(Stage stage) throws Exception
          {
              VBox box = new VBox();
              ImageView imageView = new ImageView();
              imageView.getStyleClass().add("imageView");
              box.getChildren().add(imageView);

              Scene scene = new Scene(box);
              scene.getStylesheets().add("stylesheet.css");
              stage.setScene(scene);
              stage.setWidth(1024);
              stage.setHeight(768);
              stage.show();
          }
        }

      Some interesting things of note:

      * If I set the image explicitly in code (using imageView.setImage(new Image(getClass().getResourceAsStream("images/my-image.png"), I still don't see my image
      * If I remove the -fx-image attribute however _and_ set the image in code I do see my image (and the 'hand' cursor appears when I mouse over it.

            dgrieve David Grieve
            dzwolenskjfx Daniel Zwolenski (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: