private boolean testFill2() {
    // Define an image
    int width = 256;
    int height = 256;
    int[] pixels = new int[width * height];

    ARGBScreenImage simg = new ARGBScreenImage(width, height, pixels);

    // Paint a yellow rectangle
    Graphics g = simg.image().getGraphics();
    g.setColor(Color.yellow);
    g.fillRect(0, 0, 100, 100);
    g.dispose();

    // Test whether the original array has changed
    return 0 != pixels[0];
  }
  public boolean testFillAndGrabPixel2() {
    // Define an image
    int width = 256;
    int height = 256;
    int[] pixels = new int[width * height];

    ARGBScreenImage simg = new ARGBScreenImage(width, height, pixels);

    // Paint a yellow rectangle
    Graphics g = simg.image().getGraphics();
    g.setColor(Color.yellow);
    g.fillRect(0, 0, 100, 100);
    g.dispose();

    // Paint the image, now that it has been altered, onto another image
    BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = bi.createGraphics();
    g2.drawImage(simg.image(), 0, 0, null);
    g2.dispose();

    // Test if the first pixel, as seen from the image, is yellow
    return 0x00ffff00 == (getPixel(bi, 0, 0) & 0x00ffffff);
  }
  public boolean testFillAndPaintPanelAndGrab2()
      throws InterruptedException, InvocationTargetException {
    // Define an image
    final int width = 256;
    final int height = 256;
    int[] pixels = new int[width * height];

    final ARGBScreenImage simg = new ARGBScreenImage(width, height, pixels);

    // Paint a yellow rectangle
    Graphics g = simg.image().getGraphics();
    g.setColor(Color.yellow);
    g.fillRect(0, 0, 100, 100);
    g.dispose();

    final BufferedImage[] capture = new BufferedImage[1];
    final JFrame[] frame = new JFrame[2];

    // Show the image in a JFrame
    SwingUtilities.invokeAndWait(
        new Runnable() {
          public void run() {
            frame[0] = frame(simg.image(), "Test ARGBScreenImage");
            frame[0].setVisible(true);
          }
        });

    // Wait for all sorts of asynchronous events
    Thread.sleep(2000);

    SwingUtilities.invokeAndWait(
        new Runnable() {
          public void run() {
            // Paint into the image again
            Graphics g2 = simg.image().getGraphics();
            g2.setColor(Color.red);
            g2.fillRect(100, 100, 100, 100);
            g2.dispose();
            JPanel panel = (JPanel) frame[0].getContentPane().getComponent(0);
            panel.invalidate();
            panel.validate();
            panel.repaint();
          }
        });

    // Wait for all sorts of asynchronous events
    Thread.sleep(2000);

    // Capture the image with a Robot
    SwingUtilities.invokeAndWait(
        new Runnable() {
          public void run() {
            Point panelLocation = frame[0].getContentPane().getComponent(0).getLocationOnScreen();
            Rectangle panelBounds = new Rectangle(panelLocation.x, panelLocation.y, width, height);
            Robot robot;
            try {
              robot = new Robot();
              capture[0] = robot.createScreenCapture(panelBounds);
              frame[1] = frame(capture[0], "Robot capture");
              frame[1].setVisible(true);
            } catch (AWTException e) {
              e.printStackTrace();
            }

            frame[0].dispose();
            frame[1].dispose();
          }
        });

    // Is red:
    return 0x00ff0000 == (getPixel(capture[0], 100, 100) & 0x00ffffff);
  }