The moose likes Swing / AWT / SWT / JFace and the fly likes Get Image on a JLabel Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "Get Image on a JLabel" Watch "Get Image on a JLabel" New topic
Author

Get Image on a JLabel

dushantha Rathnayake
Ranch Hand

Joined: Feb 27, 2010
Posts: 91
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
Rancher

Joined: Jun 09, 2003
Posts: 4041
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

Joined: Oct 21, 2000
Posts: 3905
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


I never took notes in college. That's how I got a 4.0 the first 2 years, and a 3.5 the second two years.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 3218

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.


luck, db
There are no new questions, but there may be new answers.
 
 
subject: Get Image on a JLabel
 
Threads others viewed
Using images within a JPanel
Problems loading image into a JLabel located in a JScrollPane
Images on JLabels
Getting coordinates on a image
humm imageIcon in an applet
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture