public static Color getPixel(int x, int y) throws AWTException {
Robot rb = new Robot();
return rb.getPixelColor(x, y);
}
public static void main(String[] args) {
JFrame f = new JFrame();
f.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
Point p = e.getLocationOnScreen();
System.out.println("Pixel:" + p.x + "," + p.y);
try {
System.out.println(getPixel(p.x, p.y));
} catch (AWTException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
}