public void actionPerformed(ActionEvent e) { if (cChooser == null) { cChooser = new JColorChooser(); } Color color = cChooser.showDialog( target, "Available Colors", ((ColoredIcon) target.getIcon()).getCurrentColor()); target.setIcon(new ColoredIcon(color)); target.doClick(); }
ColorChooserAction(JButton target) { super(null, target.getIcon()); this.target = target; }