I want to write a version of the SAND GAME.
I want to examine the color of every pixel in a Jframe window.
I use something like this.

    Toolkit toolkit =  Toolkit.getDefaultToolkit ();
    Dimension dim = toolkit.getScreenSize();
    int height = dim.height;
    int width = dim.width;

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gs = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = gs.getDefaultConfiguration();
    BufferedImage bimage = gc.createCompatibleImage(width, height, Transparency.TRANSLUCENT);

    for (int y = height - 1; y >= 0; y--) {
        for (int x = width - 1; x >= 0; x--) {
           int  rgb   = bimage.getRGB(x, y);
           int  red   = (rgb & 0x00ff0000) >> 16;
           int  green = (rgb & 0x0000ff00) >> 8;
           int  blue  = rgb & 0x000000ff;

Is it possible to create an image just of the JFrame window i use and not the hole screen?
I don't want to use the bimage.getSubimage(WIDTH, WIDTH, width, width) method or to constantly calculate the Jframe's window coordinates.
Any ideas ? Thanks for your time.

Edited 4 Years Ago by nikolaos

That's what i need. Works fine. Thanks JamesCherrill

        BufferedImage bimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics framegraphic = bimage.getGraphics();
This question has already been answered. Start a new discussion instead.