![]() |
The Java Developers Almanac 1.4 |
|
e882. Setting the Order of the Color Chooser Panel Tabs in a JColorChooser DialogThe default order of chooser panels is: swatch chooser, HSB chooser, and RGB chooser. This example demonstrates how to change the ordering. JColorChooser chooser = new JColorChooser();
// Retrieve the number of panels
int numPanels = chooser.getChooserPanels().length;
// Create an array with the desired order of panels
// findPanel() is defined in
// e880 Retrieving the Color Chooser Panels in a JColorChooser Dialog.
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");
// Set the new order of panels
chooser.setChooserPanels(newPanels);
e881. Removing a Color Chooser Panel from a JColorChooser Dialog e883. Adding a Custom Color Chooser Panel to a JColorChooser Dialog
© 2002 Addison-Wesley. |