• Post Reply Bookmark Topic Watch Topic
  • New Topic

Get Image on a JLabel

 
dushantha Rathnayake
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I did set an icon for a jlabel. In another situation i want to get the image on that jlabel. How can I get the image? please help me.

thank you.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if
"I did set an icon for a jlabel" = setIcon(..)

then
"How can I get the image?" = ?

should be easy to work out
 
Randall Twede
Ranch Hand
Posts: 4519
6
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check the JLabel API you will find a method there that returns the Icon. not sure if you can directly assign the Icon to an Image though
 
Darryl Burke
Bartender
Posts: 5152
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Randall Twede wrote:not sure if you can directly assign the Icon to an Image though

You can't. But if the Icon is an ImageIcon, you can cast and get the Image from that.

The real question here is how we should interpret what dushantha actually wants to do with the image.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!