aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Imageicon and getImage() not working with JLabels Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Imageicon and getImage() not working with JLabels" Watch "Imageicon and getImage() not working with JLabels" New topic
Author

Imageicon and getImage() not working with JLabels

Jake Freedman
Greenhorn

Joined: May 06, 2013
Posts: 1
I have a friends code using the same images with the same paths working. We simply do not understand what is wrong. Thanks for any help.




Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18909
    
    8

Scrolling through your code I couldn't see any paths or any images. But then there were several hundred lines of code so probably I couldn't pick those trees out of the forest. If you have a question about JLabel and images, could you possibly just post that code and not several hundred lines of unrelated code?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18909
    
    8

However I do have a comment about this code:



You really shouldn't use the == operator to compare the contents of two String objects for equality. You should use String's equals() method if you want to do that. But in this particular case you shouldn't be comparing any Strings anyway. Here's what that code should look like instead:


Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18909
    
    8

And sorry, should have said this before, welcome to the Ranch!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39878
    
  28
Welcome again
Paul Clapham wrote:However I do have a comment about this code:

. . .
Me too.
Whenever I see lots of if‑elses like that, I start to think that is really non‑object‑oriented code. Why are you not using a Card object? In which case your deuce can have a value of 0 and the trey a value of 1.
Actually, I have a vague memory that the cards are all worth their number value, except for the court cards: J=11, Q=12, K=13 and A=14. There would be no card with a value of 1.
You also have the problem that if you put anything which is not found or matched by the selection blocks, it will return 12 as if for an ace.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Imageicon and getImage() not working with JLabels