Program: 11202
Project: 11202
Buggy source:
private static void takeScreenshotThread(final WorldWindow wwd,int width,int height,File file){
  if (!(wwd instanceof Component))   throw new IllegalArgumentException();
  Component component=(Component)wwd;
  Container parent=component.getParent();
  JFrame frame=new JFrame();
  frame.setLayout(new BorderLayout());
  frame.setUndecorated(true);
  frame.setResizable(false);
  frame.setAlwaysOnTop(false);
  frame.add(component,BorderLayout.CENTER);
  Dimension size=new Dimension(width,height);
  component.setMinimumSize(size);
  component.setMaximumSize(size);
  component.setPreferredSize(size);
  frame.setSize(size);
  frame.setVisible(true);
  GraphicsDevice device=GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
  DisplayMode displayMode=device.getDisplayMode();
  int displayWidth=displayMode.getWidth();
  int displayHeight=displayMode.getHeight();
  final int rows=(width - 1) / displayWidth + 1;
  final int columns=(height - 1) / displayHeight + 1;
  BufferedImage bi=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
  final Graphics2D g2d=bi.createGraphics();
  for (int x=0; x < rows; x++) {
    for (int y=0; y < columns; y++) {
      final int xOffset=x * displayWidth;
      final int yOffset=y * displayHeight;
      final int screenshotWidth=Math.min(width - xOffset,displayWidth);
      final int screenshotHeight=Math.min(height - yOffset,displayHeight);
      frame.setLocation(-xOffset,-yOffset);
      BufferedImage shot=takeShot(wwd,0,0,width,height);
      g2d.drawImage(shot,xOffset,yOffset,xOffset + screenshotWidth,yOffset + screenshotHeight,xOffset,yOffset,xOffset + screenshotWidth,yOffset + screenshotHeight,null);
    }
  }
  g2d.dispose();
  String filename=file.getName();
  int dot=filename.lastIndexOf('.');
  String extension=filename.substring(dot + 1,filename.length());
  try {
    ImageIO.write(bi,extension,file);
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  parent.add(component,BorderLayout.CENTER);
  frame.dispose();
}

Fixed version (ground truth):
private static void takeScreenshotThread(WorldWindow wwd,int width,int height,File file){
  if (!(wwd instanceof Component))   throw new IllegalArgumentException();
  Component component=(Component)wwd;
  Container parent=component.getParent();
  JFrame frame=new JFrame();
  frame.setLayout(new BorderLayout());
  frame.setUndecorated(true);
  frame.setResizable(false);
  frame.setAlwaysOnTop(true);
  frame.add(component,BorderLayout.CENTER);
  Dimension size=new Dimension(width,height);
  component.setMinimumSize(size);
  component.setMaximumSize(size);
  component.setPreferredSize(size);
  frame.setSize(size);
  frame.setVisible(true);
  GraphicsDevice device=GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
  DisplayMode displayMode=device.getDisplayMode();
  int displayWidth=displayMode.getWidth();
  int displayHeight=displayMode.getHeight();
  final int rows=(width - 1) / displayWidth + 1;
  final int columns=(height - 1) / displayHeight + 1;
  BufferedImage bi=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
  final Graphics2D g2d=bi.createGraphics();
  for (int x=0; x < rows; x++) {
    for (int y=0; y < columns; y++) {
      final int xOffset=x * displayWidth;
      final int yOffset=y * displayHeight;
      final int screenshotWidth=Math.min(width - xOffset,displayWidth);
      final int screenshotHeight=Math.min(height - yOffset,displayHeight);
      frame.setLocation(-xOffset,-yOffset);
      BufferedImage shot=takeShot(wwd,0,0,width,height);
      g2d.drawImage(shot,xOffset,yOffset,xOffset + screenshotWidth,yOffset + screenshotHeight,xOffset,yOffset,xOffset + screenshotWidth,yOffset + screenshotHeight,null);
    }
  }
  g2d.dispose();
  String filename=file.getName();
  int dot=filename.lastIndexOf('.');
  String extension=filename.substring(dot + 1,filename.length());
  try {
    ImageIO.write(bi,extension,file);
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  parent.add(component,BorderLayout.CENTER);
  frame.dispose();
}