The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > javax.swing.colorchooser  [10 examples] > Color Chooser Panel  [4 examples]

e882. Setting the Order of the Color Chooser Panel Tabs in a JColorChooser Dialog

The 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);

 Related Examples
e880. Retrieving the Color Chooser Panels in a JColorChooser Dialog
e881. Removing a Color Chooser Panel from a JColorChooser Dialog
e883. Adding a Custom Color Chooser Panel to a JColorChooser Dialog

See also: Events    Preview Panel   


© 2002 Addison-Wesley.