JEyeDropper Demo

What Is It

The com.pump.swing.JEyeDropper is a dialog that lets the user choose a pixel color from anywhere on the screen.

How To Use It

JEyeDropper d = new JEyeDropper(owner, diameter);
ChangeListener changeListener = ...;
d.getModel().addChangeListener(changeListener);
d.setVisible(true);

How It Works

This is implemented as a modal circular JDialog that follows the mouse. It uses the java.awt.Robot class both to capture pixel data and to move the mouse.

This is modeled after the eyedropper tool we observed in macOS. (Like nearly all UI components in this codebase: it is not intended to be a pixel-perfect replica, though.)

Keyboard Support

This includes the following keyboard events:

  1. Return/enter/space selects the current pixel.
  2. Escape cancels the operation.
  3. Left/right/up/down nudges the mouse location.
  4. Plus/minus zooms in/out.