package example;
//-*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
//@homepage@
import java.awt.*;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;
import javax.swing.*;
import javax.swing.colorchooser.*;

public final class MainPanel extends JPanel {
    private MainPanel() {
        super(new BorderLayout(10, 10));

        JDialog dialog = new JDialog(SwingUtilities.getWindowAncestor(this), "JColorChooser", Dialog.ModalityType.APPLICATION_MODAL);
        JPanel buttonPanel = new JPanel();
        buttonPanel.add(new JButton("OK"));
        buttonPanel.add(new JButton("Cancel"));
        buttonPanel.add(new JButton("Reset"));

        JCheckBox swatches = new JCheckBox(UIManager.getString("ColorChooser.swatchesNameText", getLocale()));
        JCheckBox hsv = new JCheckBox(UIManager.getString("ColorChooser.hsvNameText", getLocale()));
        JCheckBox hsl = new JCheckBox(UIManager.getString("ColorChooser.hslNameText", getLocale()));
        JCheckBox rgb = new JCheckBox(UIManager.getString("ColorChooser.rgbNameText", getLocale()));
        JCheckBox cmyk = new JCheckBox(UIManager.getString("ColorChooser.cmykNameText", getLocale()));
        List<JCheckBox> list = Arrays.asList(swatches, hsv, hsl, rgb, cmyk);

        JButton button = new JButton("open JColorChooser");
        button.addActionListener(e -> {
            List<String> selected = list.stream().filter(AbstractButton::isSelected).map(AbstractButton::getText).collect(Collectors.toList());
            if (selected.isEmpty()) { // use default JColorChooser
                JColorChooser.showDialog(getRootPane(), "JColorChooser", null);
            } else {
                JColorChooser cc = new JColorChooser();
                for (AbstractColorChooserPanel p: cc.getChooserPanels()) {
                    if (!selected.contains(p.getDisplayName())) {
                        cc.removeChooserPanel(p);
                    }
                }
                dialog.getContentPane().removeAll();
                dialog.getContentPane().add(cc);
                dialog.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
                dialog.pack();
                dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(getRootPane()));
                dialog.setVisible(true);
            }
        });

        Box box = Box.createVerticalBox();
        for (AbstractButton b: list) {
            box.add(b);
            box.add(Box.createVerticalStrut(5));
        }
        add(box, BorderLayout.NORTH);
        add(button, BorderLayout.SOUTH);
        setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
        setPreferredSize(new Dimension(320, 240));
    }
    public static void main(String... args) {
        EventQueue.invokeLater(new Runnable() {
            @Override public void run() {
                createAndShowGUI();
            }
        });
    }
    public static void createAndShowGUI() {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | InstantiationException
               | IllegalAccessException | UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        }
        JFrame frame = new JFrame("@title@");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.getContentPane().add(new MainPanel());
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}

@@ -105,24 +105,49 @@
 java.awt.*;%0A
+import java.awt.event.*;%0A
 import java.
@@ -150,24 +150,24 @@
 ava.util.*;%0A
-
 import java.
@@ -381,24 +381,27 @@
 (10, 10));%0A%0A
+// 
         JDia
@@ -522,16 +522,19 @@
 MODAL);%0A
+// 
         
@@ -568,24 +568,26 @@
 anel();%0A
+//
         
 buttonPa
@@ -570,32 +570,33 @@
 el();%0A//        
+ 
 buttonPanel.add(
@@ -611,24 +611,27 @@
 ton(%22OK%22));%0A
+// 
         butt
@@ -662,24 +662,27 @@
 %22Cancel%22));%0A
+// 
         butt
@@ -1552,24 +1552,49 @@
 .toList());%0A
+            Color color;%0A
             
@@ -1655,32 +1655,40 @@
 %0A               
+ color =
  JColorChooser.s
@@ -2036,32 +2036,965 @@
               %7D%0A
+%0A                // ActionListener ok = ev -%3E %7B%0A                //     Color color = cc.getColor();%0A                //     System.out.println(%22ActionListener: %22 + color);%0A                // %7D;%0A                // JDialog dialog = JColorChooser.createDialog(getRootPane(), %22JColorChooser%22, true, cc, ok, null);%0A                JDialog dialog = JColorChooser.createDialog(getRootPane(), %22JColorChooser%22, true, cc, null, null);%0A                // dialog.addComponentListener(new ColorChooserDialog.DisposeOnClose());%0A                dialog.addComponentListener(new ComponentAdapter() %7B%0A                    @Override public void componentHidden(ComponentEvent e) %7B%0A                        ((Window) e.getComponent()).dispose();%0A                    %7D%0A                %7D);%0A                dialog.setVisible(true); // blocks until user brings dialog down...%0A                // return ok.getColor();%0A                color = cc.getColor();%0A%0A// 
                 
@@ -3026,24 +3026,27 @@
 emoveAll();%0A
+// 
             
@@ -3082,16 +3082,19 @@
 dd(cc);%0A
+// 
         
@@ -3155,32 +3155,35 @@
 rLayout.SOUTH);%0A
+// 
                 
@@ -3189,32 +3189,35 @@
  dialog.pack();%0A
+// 
                 
@@ -3291,24 +3291,27 @@
 otPane()));%0A
+// 
             
@@ -3345,32 +3345,71 @@
 ;%0A            %7D%0A
+            System.out.println(color);%0A
         %7D);%0A%0A   

use JColorChooser.createDialog(...) instead of new JDialog()