Setting the Order of the Color Chooser Panel Tabs in a JColorChooser Dialog
import javax.swing.JColorChooser;
import javax.swing.colorchooser.AbstractColorChooserPanel;
public class Main {
public static void main(String[] argv) {
JColorChooser chooser = new JColorChooser();
int numPanels = chooser.getChooserPanels().length;
AbstractColorChooserPanel[] newPanels = new AbstractColorChooserPanel[numPanels];
newPanels[0] = findPanel(chooser, "javax.swing.colorchooser.DefaultHSBChooserPanel");
newPanels[1] = findPanel(chooser, "javax.swing.colorchooser.DefaultRGBChooserPanel");
newPanels[2] = findPanel(chooser, "javax.swing.colorchooser.DefaultSwatchChooserPanel");
chooser.setChooserPanels(newPanels);
}
public static AbstractColorChooserPanel findPanel(JColorChooser chooser, String name) {
AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
for (int i = 0; i < panels.length; i++) {
String clsName = panels[i].getClass().getName();
if (clsName.equals(name)) {
return panels[i];
}
}
return null;
}
}
Related examples in the same category