Good morning, I have a problem, and I do not know how to get the image of a jpanel and transform it to an Image object, I tried with the following code:
private static BufferedImage createImage(JPanel panel) {
int w = panel.getWidth();
int h = panel.getHeight();
BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g = bi.createGraphics();
panel.print(g);
return bi;
}
But of course I do not know how to convert from BufferedImage to Image. Someone can help me out, it would be very helpful.
Thanks in advance.