List of usage examples for java.awt Robot getPixelColor
public synchronized Color getPixelColor(int x, int y)
From source file:Main.java
public static void main(String[] args) throws Exception { Robot robot = new Robot(); Color color = robot.getPixelColor(20, 20); System.out.println("Red = " + color.getRed()); System.out.println("Green = " + color.getGreen()); System.out.println("Blue = " + color.getBlue()); }
From source file:Main.java
public static Color getPointerColor() throws AWTException { Point coordinates = MouseInfo.getPointerInfo().getLocation(); Robot robot = new Robot(); return robot.getPixelColor((int) coordinates.getX(), (int) coordinates.getX()); }
From source file:com.jaspersoft.studio.property.color.chooser.AdvancedColorWidget.java
/** * Read the color under the mouse position and set it as the current color. This * is done only if JSS or one of its components are focused. It is necessary to control * this dialog and its content because it modal, so every other component of JSS can not be focused *//* ww w.j a va 2 s . com*/ private void checkColorPicker() { if (!isDisposed() && (getShell().isFocusControl() || checkControlFocused(getShell().getChildren()))) { Robot robot; try { robot = new Robot(); Point pos = Display.getCurrent().getCursorLocation(); java.awt.Color color = robot.getPixelColor(pos.x, pos.y); RGB rgbColor = new RGB(color.getRed(), color.getGreen(), color.getBlue()); colorsSelector.setSelectedColor(rgbColor, false); updateText(rgbColor, rgbColor.getHSB(), null); } catch (AWTException e) { e.printStackTrace(); } } }