How can i get my program to read the rgb values under my mouse while i hover over the screen and have a Jframe display the color itself. the rgb values. and possibly the name of the color
So as my title displays i need a pixel color detector
here is what i have so far it opens the jframe but does nothing else
package project;
import java.awt.AWTException;
import java.awt.Color;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.PointerInfo;
import java.awt.Robot;
import javax.swing.JFrame;
public class Project {
private static int EXIT_ON_CLOSE;
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws AWTException {
//timer = new Timer(1000,this);
JFrame frame= new JFrame();
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
//JLabel lable = new JLabel();
//JScrollPane jsp = new JScrollPane(lable);
//frame.getContentPane().add(jsp);
frame. setSize(1000, 700);
frame.setVisible(true);
while(true) {
PointerInfo cursorLocation = MouseInfo.getPointerInfo();
Point position = cursorLocation.getLocation();
int x = (int)position.getX();
int y = (int)position.getY();
Robot bob = new Robot();
Color pixelColor = bob.getPixelColor(x, y);
int colorRed = pixelColor.getRed();
int colorGreen = pixelColor.getGreen();
int colorBlue = pixelColor.getBlue();
//System.out.print("Red " + colorRed + " Green " + colorGreen + " Blue " + colorBlue + "\n" );
frame.setName("Red " + colorRed + " Green " + colorGreen + " Blue " + colorBlue );
}
}
}