在JFrame例如,下面的代码被添加
//自己的JPanel
DrawPanel drawPanel = new DrawPanel(list, width, height, start, end);
// 必需要有大小
drawPanel.setSize(width, height);
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
drawPanel.paint(g2);
try {
ImageIO.write(image, "jpeg", new File("jpanel.jpg"));
} catch (IOException e) {
e.printStackTrace();
}
版权声明:本文博客原创文章,博客,未经同意,不得转载。