'How can i use getResource(...) to grab the .png file from resources [duplicate]
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!
Solution 1:[1]
Image pencil = new Image(getClass().getResourceAsStream("/img/pencil.png"));
This solved my issue.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | dario bronders |
