How can we get the image(in png,gif,jpeg)from the icon that is set on a JButton using the setIcon() method?
I need to retrieve this image and save it in any of the availble file formats(jpg,png or gif)
Here is my sample code
So basically I want to retrieve "javalog.gif" and save it somewhere.
I tried to use some Image.getImage() method but dint know how to proceed further.
Any help is much appreciated
a) You should NOT be overriding the paint() method of JFrame.
b) There is no need to do custom painting you can just add an Icon to a label and add the label to the frame
c) If you do need custom painting then you should be overriding the paintComponent() method NOT the paint() method of a JPanel or JComponent.
Read the section from the Swing tutorial for more information about Icons and Custom Painting.