To get a Image
instance of a Imageicon
type, simply use the getImage()
:
Image img = seuIcon.getImage();
Simple like this;).
And to convert to BufferedImage
, try as suggested in this SOen response :
BufferedImage bi = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_RGB);
Graphics g = bi.createGraphics();
// paint the Icon to the BufferedImage.
icon.paintIcon(null, g, 0,0);
g.dispose();
The ideal would be to save only the path of the image and itself in some directory of the server, but if you want to continue and save in the database, usually the format is blob, but you do not need to convert to bufferedimage or image.