• Post Reply Bookmark Topic Watch Topic
  • New Topic

Loading File from source?  RSS feed

 
Vladde Nordholm
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, this is my first question on this forum!

My problem is that I want to load an Image from the source directory in Canavas' paint() method.
My code is currently (in a try/catch)

Where imageLocation leads to an image on my HDD ("C:\\Users\\Vladde\\Documents\\Folders-Files\\folder.png").


I've previously made a small program which loads images from the source dir without any problems, and the code is:


But when I tried putting in:

I get the exception: Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: input == null!
The folder setup are the same, so I'm guessing the problem lies within the code.

All help is very appreciated. Thanks.
 
Joel Christophel
Ranch Hand
Posts: 250
1
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the problem is not in your code but in the placement of your image.

This is my current setup. The images folder is located in the same directory as my Java file.



Note that I had to use .class since I'm in a static method.
 
Campbell Ritchie
Marshal
Posts: 55768
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!