Java JColorChooser handle change event

Description

Java JColorChooser handle change event

import java.awt.Color;

import javax.swing.JColorChooser;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class Main {

   public static void main(String[] a) {
      final JColorChooser tcc = new JColorChooser();
      tcc.getSelectionModel().addChangeListener(new ChangeListener() {
         public void stateChanged(ChangeEvent e) {
            System.out.println(tcc.getColor());
         }/*from  www.j  a  va  2  s  . co  m*/
      });
      tcc.showDialog(null, "title", Color.RED);
   }

}



PreviousNext

Related