Bir bileşenin ve tüm alt bileşenlerinin içeriğini bir bitmap'e çizmem gerekiyor. i tüm bileşen çizmek istiyorsanız aşağıdaki kod mükemmel çalışıyor:Java Boya bileşenini bitmap haline getirme
public void printComponent(Component c, String format, String filename) throws IOException {
// Create a renderable image with the same width and height as the component
BufferedImage image = new BufferedImage(c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB);
// Render the component and all its sub components
c.paintAll(image.getGraphics());
// Render the component and ignoring its sub components
c.paint(image.getGraphics());
// Save the image out to file
ImageIO.write(image, format, new File(filename));
}
ama sadece bir bölge Bu bileşenin çizmek için bir yol bulamadık. Herhangi bir fikrin var mı?
Bileşenin bölgeyi bitmap'teki 0,0 noktasında başlamasına neden olmaz! – Arutha
Ayarladığım klibin bir örneği vardı, bu bölgeyi sizin için yararlı bir şeye ayarlamanız gerekiyor. – dacwe
Nokta (100,100) ve 100 * 100'lik bir siez ile bölgeyi çizmek istiyorum, 100 * 100 boyutunda bir bitmap oluşturmam gerekiyor ve bu yüzden setClip yöntemi için parametreler nelerdir? – Arutha