0

Project Structure

This is one of things I have tried: In class 'EditScreenController.java':

Button placeholderEdit = new Button();
Image pencil = new Image(getClass().getResourceAsStream("pencil.png"));

placeholderEdit.setGraphic(new ImageView(pencil));

Result:

 Input stream must not be null

I know it's something super simple, and yet I have already tried multiple things :( . Would highly appreciate a working answer.

Enjoy the rest of your day!

darjow
  • 39
  • 8
  • Have you tried "img/pencil.png"? I think it doesn't work because you get files from the resources folder but the image itself in the nested folder. – Dmytro Chasovskyi Apr 27 '22 at 19:37
  • Thanks for the respond, i tried "img/pencil.png", but that one didn't work. "/img/pencil.png" did the job tho! – darjow Apr 27 '22 at 19:39

1 Answers1

1
Image pencil = new Image(getClass().getResourceAsStream("/img/pencil.png"));

This solved my issue.

darjow
  • 39
  • 8