MultiLookAndFeel (Java SE 26 & JDK 26)
Description: declaration: module: java.desktop, package: javax.swing.plaf.multi, class: MultiLookAndFeel
Keywords: javax.swing.plaf.multi.MultiLookAndFeel class

# Class MultiLookAndFeel

java.lang.Object
javax.swing.LookAndFeel
javax.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 JavaBeans has been added to the `java.beans` package. Please see `XMLEncoder`.

See Also:
  - `UIManager.addAuxiliaryLookAndFeel(LookAndFeel)`
  - `javax.swing.plaf.multi`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MultiLookAndFeel()`
  Constructs a `MultiLookAndFeel`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static ComponentUI`
  `createUIs(ComponentUI mui, Vector<ComponentUI> uis, 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.
  `UIDefaults`
  `getDefaults()`
  Creates, initializes, and returns the look and feel specific defaults.
  `String`
  `getDescription()`
  Returns a one-line description of this look and feel.
  `String`
  `getID()`
  Returns a string, suitable for use by applications/services, that identifies this look and feel.
  `String`
  `getName()`
  Returns a string, suitable for use in menus, that identifies this look and feel.
  `boolean`
  `isNativeLookAndFeel()`
  Returns `false`; this look and feel is not native to any platform.
  `boolean`
  `isSupportedLookAndFeel()`
  Returns `true`; every platform permits this look and feel.
  `protected static ComponentUI[]`
  `uisToArray(Vector<? extends ComponentUI> uis)`
  Creates an array, populates it with UI objects from the passed-in vector, and returns the array.

  ### Methods declared in class LookAndFeel

  `getDesktopPropertyValue, getDisabledIcon, getDisabledSelectedIcon, getLayoutStyle, getSupportsWindowDecorations, initialize, installBorder, installColors, installColorsAndFont, installProperty, loadKeyBindings, makeComponentInputMap, makeIcon, makeInputMap, makeKeyBindings, provideErrorFeedback, toString, uninitialize, uninstallBorder`
  Modifier and Type
  Method
  Description
  `static Object`
  `getDesktopPropertyValue(String systemPropertyName, Object fallbackValue)`
  Returns the value of the specified system desktop property by invoking `Toolkit.getDefaultToolkit().getDesktopProperty()`.
  `Icon`
  `getDisabledIcon(JComponent component, Icon icon)`
  Returns an `Icon` with a disabled appearance.
  `Icon`
  `getDisabledSelectedIcon(JComponent component, Icon icon)`
  Returns an `Icon` for use by disabled components that are also selected.
  `LayoutStyle`
  `getLayoutStyle()`
  Returns the `LayoutStyle` for this look and feel.
  `boolean`
  `getSupportsWindowDecorations()`
  Returns `true` if the `LookAndFeel` returned `RootPaneUI` instances support providing `Window` decorations in a `JRootPane`.
  `void`
  `initialize()`
  Initializes the look and feel.
  `static void`
  `installBorder(JComponent c, String defaultBorderName)`
  Convenience method for setting a component's border property with a value from the defaults.
  `static void`
  `installColors(JComponent c, String defaultBgName, String defaultFgName)`
  Convenience method for setting a component's foreground and background color properties with values from the defaults.
  `static void`
  `installColorsAndFont(JComponent c, String defaultBgName, String defaultFgName, String defaultFontName)`
  Convenience method for setting a component's foreground, background and font properties with values from the defaults.
  `static void`
  `installProperty(JComponent c, String propertyName, Object propertyValue)`
  Convenience method for installing a property with the specified name and value on a component if that property has not already been set by the developer.
  `static void`
  `loadKeyBindings(InputMap retMap, Object[] keys)`
  Populates an `InputMap` with the specified bindings.
  `static ComponentInputMap`
  `makeComponentInputMap(JComponent c, Object[] keys)`
  Creates a `ComponentInputMapUIResource` from `keys`.
  `static Object`
  `makeIcon(Class<?> baseClass, String gifFile)`
  Creates and returns a `UIDefault.LazyValue` that loads an image.
  `static InputMap`
  `makeInputMap(Object[] keys)`
  Creates an `InputMapUIResource` from `keys`.
  `static JTextComponent.KeyBinding[]`
  `makeKeyBindings(Object[] keyBindingList)`
  Convenience method for building an array of `KeyBindings`.
  `void`
  `provideErrorFeedback(Component component)`
  Invoked when the user attempts an invalid operation, such as pasting into an uneditable `JTextField` that has focus.
  `String`
  `toString()`
  Returns a string that displays and identifies this object's properties.
  `void`
  `uninitialize()`
  Uninitializes the look and feel.
  `static void`
  `uninstallBorder(JComponent c)`
  Convenience method for uninstalling a border.

  ### Methods declared in class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `protected Object`
  `clone()`
  Creates and returns a copy of this object.
  `boolean`
  `equals(Object obj)`
  Indicates whether some other object is "equal to" this one.
  `protected void`
  `finalize()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Finalization is deprecated and subject to removal in a future release.
  `final Class<?>`
  `getClass()`
  Returns the runtime class of this `Object`.
  `int`
  `hashCode()`
  Returns a hash code value for this object.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `final void`
  `wait()`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
  `final void`
  `wait(long timeoutMillis)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
  `final void`
  `wait(long timeoutMillis, int nanos)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

- ## Constructor Details

  - ### MultiLookAndFeel

    public MultiLookAndFeel()
    Constructs a `MultiLookAndFeel`.

- ## Method Details

  - ### getName

    public String getName()
    Returns a string, suitable for use in menus, that identifies this look and feel.
    Specified by:
      `getName` in class `LookAndFeel`
    Returns:
      a string such as "Multiplexing Look and Feel"

  - ### getID

    public String getID()
    Returns a string, suitable for use by applications/services, that identifies this look and feel.
    Specified by:
      `getID` in class `LookAndFeel`
    Returns:
      "Multiplex"

  - ### getDescription

    public String getDescription()
    Returns a one-line description of this look and feel.
    Specified by:
      `getDescription` in class `LookAndFeel`
    Returns:
      a descriptive string such as "Allows multiple UI instances per component instance"

  - ### isNativeLookAndFeel

    public boolean isNativeLookAndFeel()
    Returns `false`; this look and feel is not native to any platform.
    Specified by:
      `isNativeLookAndFeel` in class `LookAndFeel`
    Returns:
      `false`

  - ### isSupportedLookAndFeel

    public boolean isSupportedLookAndFeel()
    Returns `true`; every platform permits this look and feel.
    Specified by:
      `isSupportedLookAndFeel` in class `LookAndFeel`
    Returns:
      `true`
    See Also:
      - `UIManager.setLookAndFeel(LookAndFeel)`

  - ### getDefaults

    public UIDefaults getDefaults()
    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").
    Overrides:
      `getDefaults` in class `LookAndFeel`
    Returns:
      an initialized `UIDefaults` object
    See Also:
      - `JComponent.getUIClassID()`

  - ### createUIs

    public static ComponentUI createUIs(ComponentUI mui, Vector<ComponentUI> uis, 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.

    Parameters:
      `mui` - the `ComponentUI` object that represents the complete UI for the `target` component; this should be an instance of one of the `MultiXxxxUI` classes
      `uis` - a `Vector`; generally this is the `uis` field of the `mui` argument
      `target` - a component whose UI is represented by `mui`
    Returns:
      `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 Also:
      - `UIManager.getAuxiliaryLookAndFeels()`
      - `UIDefaults.getUI(JComponent)`
      - `MultiButtonUI.uis`
      - `MultiButtonUI.createUI(JComponent)`

  - ### uisToArray

    protected static ComponentUI[] uisToArray(Vector<? extends ComponentUI> 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`.
    Parameters:
      `uis` - a vector containing `ComponentUI` objects
    Returns:
      an array equivalent to the passed-in vector