Substance API

View all API methods.

View all client properties.

API method

public static void registerSkinChangeListener(
      SkinChangeListener skinChangeListener)


Registers a new listener on skin change.


  • skinChangeListener - New listener on skin change.

See also

Sample code

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Vector;

import javax.swing.*;

import org.pushingpixels.substance.api.SubstanceLookAndFeel;

 * Test application that shows the use of the
 {@link SubstanceLookAndFeel#registerSkinChangeListener(SkinChangeListener)}
 * API.
 @author Kirill Grouchnikov
 @see SubstanceLookAndFeel#registerSkinChangeListener(SkinChangeListener)
public class RegisterSkinChangeListener extends JFrame {
   * Creates the main frame for <code>this</code> sample.
  public RegisterSkinChangeListener() {
    super("Register skin change listener");

    this.setLayout(new BorderLayout());

    JPanel panel = new JPanel(new FlowLayout());

    // Get all skin display names and set the vector as a model
    // for combobox.
    final JComboBox cb = new JComboBox(new Vector<String>(

    cb.addItemListener(new ItemListener() {
      public void itemStateChanged(ItemEvent evt) {
        // Get the affected item
        final Object item = evt.getItem();

        if (evt.getStateChange() == ItemEvent.SELECTED) {
          SwingUtilities.invokeLater(new Runnable() {
            public void run() {
              try {
                // Get the skin info object based on
                // the selected skin display name
                SkinInfo skinInfo = SubstanceLookAndFeel
                // Set the global skin based on the
                // skin class name.
              catch (Exception exc) {

    panel.add(new JLabel("All skins:"));

    this.add(panel, BorderLayout.CENTER);

    // register listener
        .registerSkinChangeListener(new SkinChangeListener() {
          public void skinChanged() {
            // show dialog with skin changed message.
            SwingUtilities.invokeLater(new Runnable() {
              public void run() {
                    "Skin changed");


   * The main method for <code>this</code> sample. The arguments are ignored.
   @param args
   *            Ignored.
  public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin());
        new RegisterSkinChangeListener().setVisible(true);

The screenshot below shows an option pane that pops up from the registered skin listener. Note that the dialog is skinned with the new skin (Business):