FileDocCategorySizeDatePackage
MultiLookAndFeel.javaAPI DocJava SE 6 API9949Tue Jun 10 00:26:52 BST 2008javax.swing.plaf.multi

MultiLookAndFeel

public class MultiLookAndFeel extends LookAndFeel

A multiplexing look and feel that allows more than one UI to be associated with a component at the same time. The primary look and feel is called the default look and feel, and the other look and feels are called auxiliary.

For further information, see Using the Multiplexing Look and Feel.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see {@link java.beans.XMLEncoder}.

see
UIManager#addAuxiliaryLookAndFeel
see
javax.swing.plaf.multi
version
1.36 02/19/06
author
Willie Walker

Fields Summary
Constructors Summary
Methods Summary
public static javax.swing.plaf.ComponentUIcreateUIs(javax.swing.plaf.ComponentUI mui, java.util.Vector uis, javax.swing.JComponent target)
Creates the ComponentUI objects required to present the target component, placing the objects in the uis vector and returning the ComponentUI object that best represents the component's UI. This method finds the ComponentUI objects by invoking getDefaults().getUI(target) on each default and auxiliary look and feel currently in use. The first UI object this method adds to the uis vector is for the default look and feel.

This method is invoked by the createUI method of MultiXxxxUI classes.

param
mui the ComponentUI object that represents the complete UI for the target component; this should be an instance of one of the MultiXxxxUI classes
param
uis a Vector; generally this is the uis field of the mui argument
param
target a component whose UI is represented by mui
return
mui if the component has any auxiliary UI objects; otherwise, returns the UI object for the default look and feel or null if the default UI object couldn't be found
see
javax.swing.UIManager#getAuxiliaryLookAndFeels
see
javax.swing.UIDefaults#getUI
see
MultiButtonUI#uis
see
MultiButtonUI#createUI

        ComponentUI ui;

        // Make sure we can at least get the default UI
        //
        ui = UIManager.getDefaults().getUI(target);
        if (ui != null) {
            uis.addElement(ui);
            LookAndFeel[] auxiliaryLookAndFeels;
	    auxiliaryLookAndFeels = UIManager.getAuxiliaryLookAndFeels();
            if (auxiliaryLookAndFeels != null) {
                for (int i = 0; i < auxiliaryLookAndFeels.length; i++) {
                    ui = auxiliaryLookAndFeels[i].getDefaults().getUI(target);
                    if (ui != null) {
                        uis.addElement(ui);
                    }
                }
	    }
        } else {
	    return null;
	}

        // Don't bother returning the multiplexing UI if all we did was
        // get a UI from just the default look and feel.
        //
	if (uis.size() == 1) {
	    return (ComponentUI) uis.elementAt(0);
	} else {
	    return mui;
	}
    
public javax.swing.UIDefaultsgetDefaults()
Creates, initializes, and returns the look and feel specific defaults. For this look and feel, the defaults consist solely of mappings of UI class IDs (such as "ButtonUI") to ComponentUI class names (such as "javax.swing.plaf.multi.MultiButtonUI").

return
an initialized UIDefaults object
see
javax.swing.JComponent#getUIClassID

	String packageName = "javax.swing.plaf.multi.Multi";
	Object[] uiDefaults = {
		   "ButtonUI", packageName + "ButtonUI",
	 "CheckBoxMenuItemUI", packageName + "MenuItemUI",
		 "CheckBoxUI", packageName + "ButtonUI",
             "ColorChooserUI", packageName + "ColorChooserUI",
		 "ComboBoxUI", packageName + "ComboBoxUI",
	      "DesktopIconUI", packageName + "DesktopIconUI",
	      "DesktopPaneUI", packageName + "DesktopPaneUI",
               "EditorPaneUI", packageName + "TextUI",
              "FileChooserUI", packageName + "FileChooserUI",
       "FormattedTextFieldUI", packageName + "TextUI",
	    "InternalFrameUI", packageName + "InternalFrameUI",
		    "LabelUI", packageName + "LabelUI",
		     "ListUI", packageName + "ListUI",
		  "MenuBarUI", packageName + "MenuBarUI",
		 "MenuItemUI", packageName + "MenuItemUI",
		     "MenuUI", packageName + "MenuItemUI",
	       "OptionPaneUI", packageName + "OptionPaneUI",
	            "PanelUI", packageName + "PanelUI",
	    "PasswordFieldUI", packageName + "TextUI",
       "PopupMenuSeparatorUI", packageName + "SeparatorUI",
		"PopupMenuUI", packageName + "PopupMenuUI",
	      "ProgressBarUI", packageName + "ProgressBarUI",
      "RadioButtonMenuItemUI", packageName + "MenuItemUI",
	      "RadioButtonUI", packageName + "ButtonUI",
	         "RootPaneUI", packageName + "RootPaneUI",
		"ScrollBarUI", packageName + "ScrollBarUI",
	       "ScrollPaneUI", packageName + "ScrollPaneUI",
		"SeparatorUI", packageName + "SeparatorUI",
		   "SliderUI", packageName + "SliderUI",
		  "SpinnerUI", packageName + "SpinnerUI",
		"SplitPaneUI", packageName + "SplitPaneUI",
	       "TabbedPaneUI", packageName + "TabbedPaneUI",
	      "TableHeaderUI", packageName + "TableHeaderUI",
		    "TableUI", packageName + "TableUI",
		 "TextAreaUI", packageName + "TextUI",
		"TextFieldUI", packageName + "TextUI",
		 "TextPaneUI", packageName + "TextUI",
	     "ToggleButtonUI", packageName + "ButtonUI",
         "ToolBarSeparatorUI", packageName + "SeparatorUI",
		  "ToolBarUI", packageName + "ToolBarUI",
		  "ToolTipUI", packageName + "ToolTipUI",
		     "TreeUI", packageName + "TreeUI",
		 "ViewportUI", packageName + "ViewportUI",
	};

        UIDefaults table = new MultiUIDefaults(uiDefaults.length / 2, 0.75f);
	table.putDefaults(uiDefaults);
	return table;
    
public java.lang.StringgetDescription()
Returns a one-line description of this look and feel.

return
a descriptive string such as "Allows multiple UI instances per component instance"

        return "Allows multiple UI instances per component instance";
    
public java.lang.StringgetID()
Returns a string, suitable for use by applications/services, that identifies this look and feel.

return
"Multiplex"

	return "Multiplex";
    
public java.lang.StringgetName()
Returns a string, suitable for use in menus, that identifies this look and feel.

return
a string such as "Multiplexing Look and Feel"

        return "Multiplexing Look and Feel";
    
public booleanisNativeLookAndFeel()
Returns false; this look and feel is not native to any platform.

return
false

	return false;
    
public booleanisSupportedLookAndFeel()
Returns true; every platform permits this look and feel.

return
true

	return true;
    
protected static javax.swing.plaf.ComponentUI[]uisToArray(java.util.Vector uis)
Creates an array, populates it with UI objects from the passed-in vector, and returns the array. If uis is null, this method returns an array with zero elements. If uis is an empty vector, this method returns null. A run-time error occurs if any objects in the uis vector are not of type ComponentUI.

param
uis a vector containing ComponentUI objects
return
an array equivalent to the passed-in vector

        if (uis == null) {
            return new ComponentUI[0];
        } else {
            int count = uis.size();
            if (count > 0) {
                ComponentUI[] u = new ComponentUI[count];
                for (int i = 0; i < count; i++) {
                    u[i] = (ComponentUI)uis.elementAt(i);
                }
                return u;
            } else {
                return null;
            }
        }