Author: substance.dev.java.net
Description: Substance look and feel
Keywords: java, look, feel, skins, plaf, swing, ui, pluggable, substance

# Substance look and feel - plugins

Starting from version 2.1, Substance provides support for third-party components (for example NetBeans tabs) using plugin architecture.

### Creating a plugin

Substance plugin is a jar file that contains at least the following two files:

- META-INF/substance-plugin.xml
- Class that implements org.jvnet.substance.plugin.SubstancePlugin interface

The structure of META-INF/substance-plugin.xml descriptor is:

      <substance-plugin>
        <plugin-class>Class name</plugin-class>
      </substance-plugin>

The class name is a fully qualified name of a non-abstract class with a default zero-argument constructor that implements the org.jvnet.lafplugin.LafPlugin interface.
The LafPlugin interface specifies the following four functions which must be implemented by the plugin:

- public Map getUiDelegates(); - returns a map of all custom UI delegates. The key is UI class ID (as searched by the component itself), the value is the fully qualified name of the UI delegate.
- public Map getFonts(); - returns a map of all custom font settings. The key is symbolic reference (as searched in the UI delegate), the value is the Font object.
- public Object[] getDefaults(Object themeObject); - returns an array of UI default settings that match the specified information on the current theme. The entries in the array should be pairwise, the symbolic key (String) and the value (object as searched in the UI delegate).
- public void initialize(); - initializes the plugin.
- public void reset(); - should reset all theme-dependant caches in the UI delegates.

Note that the plugin jar doesn't have to contain the UI delegates that are specified in its getUiDelegates function, as long as they are somewhere in the classpath.

### Built-in plugin

Substance comes bundled with a built-in plugin for a color chooser (from Quaqua look and feel). The corresponding files are:

- META-INF/substance-plugin.xml.
- org.jvnet.substance.plugin.BasePlugin that is pointed to from the plugin descriptor file.

See the implementation of the BasePlugin class for the reference.

### Using third-party plugins

In order to use a third-party plugin, just put it in the classpath (along with the substance.jar) and it will be picked up automatically.