saving an image

Hi everyone,

I'm using JFileChooser to save an image, using the showSaveDialog. My problem is that I can't use ImageIO.write as I'm not using buffered image but instead I'm using ImageIcon, stuffed in a label and displayed using JInternalFrame. Is there any other methods to save an ImageIcon other than using ImageIO.write and casting my ImageIcon to RenderedImage like that (RenderedImage)myFrame.getImage() in the ImageIO.write function???

Not possible. JFileChooser doesn't save (nor open) a file. It provides the api to select a file.

I can't use ImageIO.write as I'm not using buffered image but instead I'm using ImageIcon

1. ImageIO#write(...) takes a RenderedImage, not a BufferedImage argument.
2. Get the Image form the ImageIcon and paint it to a newly created BufferedImage of the same size and appropriate type. Than save the BufferedImage.

casting my ImageIcon to RenderedImage like that (RenderedImage)myFrame.getImage()

Huh? Don't know what you're trying to express, but you can't cast something to something else that it isn't. You can only cast ImageIcon#getImage(...) to a Buffered image if the image contained in the icon really is a BufferedImage, in which case you would have a reference to the image you used to construct (or setImage) the ImageIcon and wouldn't need to retrieve it from getImage.