0

im trying to load a image from src folder

the file: /src/Imagens/user_login.png

but the getResource doesnt work :( i tryed to solve, but look the images

First Try:

enter image description here

Second Try, removing the getClass for the Class real name:

enter image description here

Third Try, lets add a .class after the name "Oh, i think i solved":

enter image description here

DAMM!!! what can i do? i can use the IMageIcon for Images in C:/ or other location, but from the src, i cant

user2582318
  • 1,607
  • 5
  • 29
  • 47

1 Answers1

2

You try to acces non static method getClass() from static context(method main()). You can use from static context:

inicializador_tela_login.class.getResource(...)

or create instance of class and use getClass() method:

new inicializador_tela_login().getClass().getResource(...)
alex2410
  • 10,904
  • 3
  • 25
  • 41