Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.AWTException;
import java.awt.Color;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Robot;

public class Main {

    public static void main(String[] args) throws Exception {
        System.out.println(getPointerColor());
    }

    public static Color getPointerColor() throws AWTException {
        Point coordinates = MouseInfo.getPointerInfo().getLocation();
        Robot robot = new Robot();
        return robot.getPixelColor((int) coordinates.getX(), (int) coordinates.getX());
    }
}