Resolved How To Load An Image From Resources

Discussion in 'Developer Support' started by Stopper Blocker, May 13, 2016.

  1. I have an imageView in a '.FXML' file and I want to provide it an image. Is there a way to do it manually, in SceneBuilder? If not, how would I do it using the Resources class? I have tried using the following but without luck:
    Code (Text):
    1. Resources.getAsBufferedImage(SOME_IMAGE_STR)
  2. Best Answer:
    Post #2 by Party, May 13, 2016
  3. @FXML
    private ImageView img;


    //In your initialise
    Image image = new Image(Resources.getAsStream("path to your image"));

    ^^ From memory, feel free to correct me @Savior
    --- Double Post Merged, May 13, 2016, Original Post Date: May 13, 2016 ---
    Also, you should join the developer Slack chat, you're likely to get a quicker answer.

    Stopper Blocker likes this.
  4. Don't forget to add it as a <resource> in your manifest.
    Stopper Blocker likes this.
  5. @Party, @proxi,

    Thanks guys!

    Also, that's true, I should join the Slack channel.
    proxi likes this.

Share This Page