i made this code where you get the pixel color number where ever the mouse is moving the problem is i want it to show up in a jframe and make the JFrame background change color according to the pixel color. For example if the mouse was on white it would print out 255,255,255 and i would like it to show on the Jfream red=255,blue=255,green=255 and then get the background to change white. Could someone help me out and point me to the right direction new to java.
[code = java]
<
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.PointerInfo;
import java.awt.Robot;
public class PixelColor {
public static void main(String[] args) throws AWTException {
PointerInfo pointer;
pointer = MouseInfo.getPointerInfo();
Point coord = pointer.getLocation();
Robot robot = new Robot();
robot.delay(2000);
while(true)
{
pointer = MouseInfo.getPointerInfo();
coord = pointer.getLocation();
System.out.println(" color: " + robot.getPixelColor(coord.x, coord.y).getRed() +
", " + robot.getPixelColor(coord.x, coord.y).getGreen() +
", " + robot.getPixelColor(coord.x, coord.y).getBlue());
}
}
}
>
[/code]