Java Swing ChangeListener handle JColorChooser change event

Description

Java Swing ChangeListener handle JColorChooser 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 w w  w .  j a  v  a2s  .co m
      });
      tcc.showDialog(null, "title", Color.RED);
   }

}



PreviousNext

Related