writing a program in JAVA that identifies the color underneath the mouse pointer and fills a JFrame with that color, and displays the RGB values of that color. This is what I have so far:
import java.awt.Component;
import java.awt.event.*;
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;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class FinalProject {
public static void main(String[] args) throws AWTException {
// sets up application window
JFrame frame = new JFrame("Color Blind Assistant");
frame.setVisible(true);
frame.setSize(500,500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// determines color underneath mouse
PointerInfo cursorLocation = MouseInfo.getPointerInfo();
Point position = cursorLocation.getLocation();
int x = (int)position.getX();
int y = (int)position.getY();
Robot colorfind = new Robot();
Color pixelColor = colorfind.getPixelColor(x, y);
int colorRed = pixelColor.getRed();
int colorGreen = pixelColor.getGreen();
int colorBlue = pixelColor.getBlue();
// sets color of application background
frame.getContentPane().setBackground(pixelColor);
// prints RGB value of color under mouse