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 ツ
  • 47,427
  • 17
  • 69
  • 97
user6408978
  • 85
  • 1
  • 2
  • 6

1 Answers1

0

Try

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

or

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