Can i use swatches panel only

68 Views Asked by At

I want to use the swatches panel pinned to a toolbar in my original JFrame without having to open a new frame with multiple panels

I tried to remove another taps but still the swatches tap opens on a new frame

JColorChooser chooser = new JColorChooser();
AbstractColorChooserPanel[] oldPanels = chooser.getChooserPanels();
for (int i = 0; i < oldPanels.length; i++) {
  String clsName = oldPanels[i].getClass().getName();
  if (clsName.equals("javax.swing.colorchooser.DefaultRGBChooserPanel")) {
    chooser.removeChooserPanel(oldPanels[i]);
  } else if (clsName.equals("javax.swing.colorchooser.DefaultHSBChooserPanel")) {
    chooser.removeChooserPanel(oldPanels[i]);
  }
}
1

There are 1 best solutions below

0
Youssef Wagdy On
JColorChooser choose = new JColorChooser();
        AbstractColorChooserPanel[] panels = choose.getChooserPanels();
        for (AbstractColorChooserPanel accp : panels) {
            if (accp.getDisplayName().equals("Swatches")) {
                JOptionPane.showMessageDialog(this, accp);
            }
        }