How to remove title bar from JFrame screenshot?

I am collecting JFrame screenshots using the "double buffering" method below:

public BufferedImage getScreenshot() {      
  java.awt.Dimension dim = this.getPreferredSize();         
  BufferedImage image = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_RGB);            
  this.paint(image.getGraphics());      
  return image;     
}

where thisextends JFrame. The image I get has an empty bar along the top where the caption was. What is the easiest way to capture an image of JFrame content without the extra space allocated for the title?

+2
source share
1 answer

You must use the Screen Image class . Simply specify the frame content area (or the root panel, if you have a menu) as the component for which the image is required.

, ( ) , , .

+5

All Articles