• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Image not showing up in GUI

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Bartender
Posts: 5465
212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
The harder you work, the luckier you get. This tiny ad brings luck - just not good luck or bad luck.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic