Substance API

View all API methods.

View all client properties.


API method

public static boolean hasMixedThemes()

Description

Checks whether there are any mixed themes registered globally.

Returns:

  • true if there is at least one mixed theme registered globally, false otherwise.

See also


Sample code

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import org.jvnet.substance.SubstanceLookAndFeel;
import org.jvnet.substance.theme.*;

/**
 * Test application that shows the use of the
 {@link SubstanceLookAndFeel#hasMixedThemes()} API.
 
 @author Kirill Grouchnikov
 @see SubstanceLookAndFeel#hasMixedThemes()
 */
public class HasMixedThemes extends JFrame {
  /**
   * Creates the main frame for <code>this</code> sample.
   */
  public HasMixedThemes() {
    super("Has mixed themes");

    this.setLayout(new BorderLayout());

    JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    final JButton addMixedTheme = new JButton(
        "Add \"Aqua & Bottle Green\" theme");
    addMixedTheme.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            addMixedTheme.setEnabled(false);
            // add one mixed theme
            SubstanceLookAndFeel
                .addMixedTheme(new SubstanceMixTheme(
                    new SubstanceAquaTheme(),
                    new SubstanceBottleGreenTheme()));
          }
        });
      }
    });
    controls.add(addMixedTheme);

    JButton hasMixedThemes = new JButton("Check mixed themes");
    hasMixedThemes.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        JOptionPane
            .showMessageDialog(
                HasMixedThemes.this,
                SubstanceLookAndFeel.hasMixedThemes() "Has mixed themes"
                    "No mixed themes");
      }
    });
    controls.add(hasMixedThemes);

    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);
    JDialog.setDefaultLookAndFeelDecorated(true);
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        new HasMixedThemes().setVisible(true);
      }
    });
  }
}

The screenshot below shows the result of calling this method when no mixed theme has been added:.

The screenshot below shows the result of calling this method after a mixed Aqua / Bottle green theme has been added:.