#Robot().getPixelColor not giving the correct color AFTER the window is moved

3 messages · Page 1 of 1 (latest)

river helm
#

frame.addMouseListener (new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
int x = e.getX();
int y = e.getY();
//Point lastPoint = e.getPoint();

                    System.out.println("Mouse Position = " + x + " " + y);
                    //System.out.println("Shape Position = " +  + " " + y);
                    try {
                        
                        
                        Color color = new Robot().getPixelColor(x, y);

                        
                        System.out.println("Red   = " + color.getRed());
                        System.out.println("Green = " + color.getGreen());
                        System.out.println("Blue  = " + color.getBlue());
                    }
                    catch (AWTException e1) {
                        e1.printStackTrace();
                    }
    }

Hello, I tried getting color of the pixel my mouse clicks on. It works perfectly fine with the JFrame on the top left of the screen, however, right after I move the window, the colors are all thrown off.

molten rockBOT
#

Hey, @river helm!
Please remember to /close this post once your question has been answered!