Substance client properties

View all API methods.

View all client properties.


Client property name

SubstanceLookAndFeel.PERMANENTLY_PINNED

Description

Client property name for specifying that a control should be permanently pinned (made immoveable). The value should be an instance of Boolean.


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;

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

    this.setLayout(new BorderLayout());

    // create a desktop pane with one internal frame
    JDesktopPane jdp = new JDesktopPane();
    final JInternalFrame jif = new JInternalFrame();
    jif.setBounds(1010300120);
    jif.setLayout(new FlowLayout(FlowLayout.CENTER));
    jif.add(new JButton("test"));
    jdp.add(jif);
    jif.setMaximizable(true);
    jif.setIconifiable(true);
    jif.setClosable(true);
    jif.setVisible(true);

    this.add(jdp, BorderLayout.CENTER);

    JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    final JCheckBox isPermanentlyPinned = new JCheckBox(
        "permanently pinned");
    isPermanentlyPinned.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            // based on the checkbox selection, mark the internal
            // frame as permanently pinned
            jif.putClientProperty(
                SubstanceLookAndFeel.PERMANENTLY_PINNED,
                isPermanentlyPinned.isSelected() ? Boolean.TRUE
                    null);
            repaint();
          }
        });
      }
    });
    controls.add(isPermanentlyPinned);
    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 PermanentlyPinned().setVisible(true);
      }
    });
  }
}

The screenshot below shows application frame with internal frame in default state (pin button is enabled) - this property is not set:

The screenshot below shows application frame with internal frame that has this property set to Boolean.TRUE: