Substance client properties

View all API methods.

View all client properties.


Client property name

SubstanceLookAndFeel.SHOW_EXTRA_WIDGETS

Description

Property name for specifying that extra UI elements (such as menu items in system menu or lock borders) should be shown. This property can be set as a global setting on UIManager or as a client property on a specific component. The value should be either Boolean.TRUE or Boolean.FALSE.


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.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import org.pushingpixels.lafwidget.LafWidget;
import org.pushingpixels.substance.api.SubstanceLookAndFeel;
import org.pushingpixels.substance.api.skin.BusinessBlackSteelSkin;

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

    this.setLayout(new BorderLayout());

    JPanel centerPanel = new JPanel(new FlowLayout());
    final JTextField readOnlyTextField = new JTextField("read-only");
    readOnlyTextField.setEditable(false);
    centerPanel.add(readOnlyTextField);

    this.add(centerPanel, BorderLayout.CENTER);

    JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    final JCheckBox showExtraWidgets = new JCheckBox("show extra widgets");
    showExtraWidgets.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            // based on the checkbox selection status, set the
            // property
            UIManager.put(SubstanceLookAndFeel.SHOW_EXTRA_WIDGETS,
                Boolean.valueOf(showExtraWidgets.isSelected()));
            readOnlyTextField
                .putClientProperty(LafWidget.HAS_LOCK_ICON,
                    Boolean.valueOf(showExtraWidgets
                        .isSelected()));
            SwingUtilities
                .updateComponentTreeUI(ShowExtraWidgets.this);
          }
        });
      }
    });
    controls.add(showExtraWidgets);
    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.
   */
  public static void main(String[] args) {
    JFrame.setDefaultLookAndFeelDecorated(true);
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin());
        new ShowExtraWidgets().setVisible(true);
      }
    });
  }
}

The screenshot below shows an uneditable text field when this property is not set:

The screenshot below shows system menu when this property is set to Boolean.TRUE. Note the lock icon in the bottom-left corner of the text field: