// implementation of java.awt.event.MouseMotionListener interface public void mouseDragged(MouseEvent e) { if (e.getSource() == cs) { int i = e.getX(); int j = e.getY(); Color c = new Color(cs.getRGB(i, j)); updateColor(c, e.getSource()); } }