Substance client properties

View all API methods.

View all client properties.


Client property name

SubstanceLookAndFeel.ENABLE_INVERTED_THEMES

Description

Property name for enabling inverted themes. This property can be set as either VM flag (no value needed) or as a global setting on UIManager. In the latter case, the value should be either Boolean.TRUE or Boolean.FALSE. When this property is set, the SubstanceLookAndFeel.getAllThemes() method will return entries for all SubstanceTheme.ThemeKind.BRIGHT and SubstanceTheme.ThemeKind.COLD themes. All these entries will be marked with SubstanceTheme.ThemeKind.INVERTED kind.


See also


Sample code

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;

import javax.swing.*;

import org.jvnet.substance.SubstanceDefaultListCellRenderer;
import org.jvnet.substance.SubstanceLookAndFeel;
import org.jvnet.substance.theme.ThemeInfo;

/**
 * Test application that shows the use of the
 {@link SubstanceLookAndFeel#ENABLE_INVERTED_THEMES} client property.
 
 @author Kirill Grouchnikov
 @see SubstanceLookAndFeel#ENABLE_INVERTED_THEMES
 */
public class EnableInvertedThemes extends JFrame {
  /**
   * Creates the main frame for <code>this</code> sample.
   */
  public EnableInvertedThemes() {
    super("Enable inverted themes");

    this.setLayout(new BorderLayout());

    final JPanel panel = new JPanel(new FlowLayout());
    final JComboBox cb = new JComboBox(new Vector<ThemeInfo>(
        SubstanceLookAndFeel.getAllThemes().values()));
    cb.setRenderer(new SubstanceDefaultListCellRenderer() {
      @Override
      public Component getListCellRendererComponent(JList list,
          Object value, int index, boolean isSelected,
          boolean cellHasFocus) {
        ThemeInfo ti = (ThemeInfovalue;
        return super
            .getListCellRendererComponent(list, ti
                .getDisplayName(), index, isSelected,
                cellHasFocus);
      }
    });
    panel.add(new JLabel("All themes:"));
    panel.add(cb);

    this.add(panel, BorderLayout.CENTER);

    JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    final JCheckBox enableInvertedThemes = new JCheckBox(
        "enable inverted themes");
    enableInvertedThemes.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            // based on the checkbox selection status, enable
            // inverted themes
            UIManager
                .put(
                    SubstanceLookAndFeel.ENABLE_INVERTED_THEMES,
                    enableInvertedThemes.isSelected() ? Boolean.TRUE
                        null);
            // reset the combobox model to all available Substance
            // themes
            cb.setModel(new DefaultComboBoxModel(
                new Vector<ThemeInfo>(SubstanceLookAndFeel
                    .getAllThemes().values())));
          }
        });
      }
    });
    controls.add(enableInvertedThemes);
    this.add(controls, BorderLayout.SOUTH);

    this.setSize(400200);
    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }

  /**
   * The main method for <code>this</code> sample. The arguments are
   * ignored.
   
   @param args
   *            Ignored.
   @throws Exception
   *             If some exception occured. Note that there is no special
   *             treatment of exception conditions in <code>this</code>
   *             sample code.
   */
  public static void main(String[] argsthrows Exception {
    UIManager.setLookAndFeel(new SubstanceLookAndFeel());
    JFrame.setDefaultLookAndFeelDecorated(true);
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        new EnableInvertedThemes().setVisible(true);
      }
    });
  }
}

The screenshot below shows a combo with all available themes when this property is not set:

The screenshot below shows a combo with all available themes when this property is set to Boolean.TRUE: