Here you can find the source of generateBufferedImageFromComponent(Component component)
Parameter | Description |
---|---|
component | Javakomponente aus der die Bilddatei erstellt werden soll |
public static BufferedImage generateBufferedImageFromComponent(Component component)
//package com.java2s; //License from project: Apache License import java.awt.Component; import java.awt.Graphics; import java.awt.image.BufferedImage; public class Main { /**//w w w. j a v a2s . c o m * Erstellt Image aus einer (Java)Komponente * * @param component * Javakomponente aus der die Bilddatei erstellt werden soll * * @return Image der Komponente */ public static BufferedImage generateBufferedImageFromComponent(Component component) { BufferedImage image = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics g = image.getGraphics(); g.setColor(component.getBackground()); g.fillRect(0, 0, image.getWidth(), image.getHeight()); component.print(g); g.dispose(); return image; } }