setSize(200, 100);
setLocation(200, 100);
final JButton go = new JButton("Show JColorChoser");
final Container contentPane = getContentPane();
go.addActionListener(new ActionListener() {
final JColorChooser chooser = new JColorChooser();
boolean first = true;
public void actionPerformed(ActionEvent e) {
if (first) {
first = false;
GrayScalePanel gsp = new GrayScalePanel();
chooser.addChooserPanel(gsp);
chooser.setPreviewPanel(new CustomPane());
}
JDialog dialog = JColorChooser.createDialog(ColorPickerSample.this,
"Demo 3", true, chooser, new ActionListener() {
public void actionPerformed(ActionEvent e) {
c = chooser.getColor();
}
}, null);
dialog.setLocation(300, 300);
dialog.setVisible(true);
contentPane.setBackground(c);