Java tutorial
import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JColorChooser; import javax.swing.JDialog; public class Main { public static void main(String[] argv) { final JColorChooser chooser = new JColorChooser(); ActionListener okListener = new ActionListener() { public void actionPerformed(ActionEvent evt) { Color newColor = chooser.getColor(); } }; ActionListener cancelListener = new ActionListener() { public void actionPerformed(ActionEvent evt) { Color newColor = chooser.getColor(); } }; boolean modal = false; JDialog dialog = JColorChooser.createDialog(null, "Dialog Title", modal, chooser, okListener, cancelListener); dialog.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { Color newColor = chooser.getColor(); } }); } }