0

I'm trying to build my first Javafx project on Netbeans, and i'ven been stuck at adding an imageview for a Label, it always returns a null exception. And now that i understand that it's because it cant locate my image i'm assuming it's because im giving the program an incorrect path..

Image image = new Image(getClass().getResource("Data/Images/Logo.jpg").toExternalForm());
Label logoLabel = new Label("Logo", new ImageView(image));

I'm trying to get an image saved on the JavaFX programs's Directory/Data/Images/Logo.jpg How do i go about reaching that location?

ΦXocę 웃 Пepeúpa ツ
  • 45,713
  • 17
  • 64
  • 91
user6408978
  • 75
  • 1
  • 2
  • 6

1 Answers1

0

Try

getClass().getResource("/Data/Images/Logo.jpg")

or

getClass().getClassLoader().getResource("Data/Images/Logo.jpg")
Cary
  • 240
  • 1
  • 7