Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how do i get an image of the icon from an JLabel

 
pinjalim bora
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey ranchers..
I have JDeskTopPane ..in which I have a JInternalFrame....in which i have a JScrollPane...on the scroll pane i have a jlabel on which i have an image set as an icon ......
Now...how do i get back a reference to the image....
pls help...
pinju
 
dheeren patel
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey try this
public Icon getIcon()
Returns the graphic image (glyph, icon) that the label displays.
Returns:
an Icon

[This message has been edited by dheeren patel (edited December 21, 2001).]
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...and once you get the Icon you have to see if it's an ImageIcon( the only icons that have images... ), so cast it to ImageIcon and call getImage(), which returns an Image.

-Nate
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic