• Post Reply Bookmark Topic Watch Topic
  • New Topic

Image not showing up in GUI

 
Madison Wrest
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have looked at several tutorials online and have looked at a couple forums as well but I cannot get my image to display on my GUI. I know it has something to do with the path but even after trying to research it I still have no clue on how to fix it. I would greatly appreciate any pointers on how to fix this problem.

Here is my code. I apologize for it not being in the best format.



[Edited to add code tags and remove unnecessary blank lines. CR]
 
Piet Souris
Rancher
Posts: 1638
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Madison,

always a nasty thing, getting these relative paths correct.

As a quick way to check whether there's anything wrong whatsoever, what I would do is to use the complete
path of the image in your ImageIcon creation.

say fullpath is a String containing the path to your image. The easiest way to get that is to use the Windows Navigator,
or the equivalent of your OS. Go to your image, and copy the adress from the address bar. Say it is c:\myImages.

Then in your code you say:

Now, this must work, since I cannot find anything wrong with your code.

I don't see you using any package statement, so let's leave that for now.

Greetings,
Piet
 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch

Always use the code button, which makes code look much better, particularly if it has short lines and good indentation. I shall try to edit your post shortly, and see if I can improve it
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!