Laf-Widget client properties

View all client properties.


Client property name

LafWidget.HAS_LOCK_ICON

Description

Client property name for specifying that the LockBorderWidget should put a lock icon. This property can be set either on a single component or globally on UIManager. The value in both cases 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 LafWidget#HAS_LOCK_ICON}
 * client property.
 
 @author Kirill Grouchnikov
 @see LafWidget#HAS_LOCK_ICON
 */
public class HasLockIcon extends JFrame {
  /**
   * Creates the main frame for <code>this</code> sample.
   */
  public HasLockIcon() {
    super("Has lock icon");

    this.setLayout(new BorderLayout());

    final JTextField jtf = new JTextField("sample text");
    jtf.setEditable(false);
    jtf.setColumns(20);

    JPanel main = new JPanel(new FlowLayout(FlowLayout.CENTER));
    this.add(main, BorderLayout.CENTER);
    main.add(jtf);

    JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT));

    final JCheckBox hasLockIcon = new JCheckBox("Has lock icon");
    hasLockIcon.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jtf.putClientProperty(LafWidget.HAS_LOCK_ICON, hasLockIcon
            .isSelected() ? Boolean.TRUE : null);
      }
    });

    controls.add(hasLockIcon);
    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 {
    JFrame.setDefaultLookAndFeelDecorated(true);
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        UIManager.put(SubstanceLookAndFeel.SHOW_EXTRA_WIDGETS,
            Boolean.TRUE);
        SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin());
        new HasLockIcon().setVisible(true);
      }
    });
  }
}

The screenshot below shows a text component when this property is not installed:

After installing this property on the text component, it has a lock icon in the bottom left corner: