Substance client properties

View all API methods.

View all client properties.


Client property name

SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY

Description

Client property name for specifying an open side for a single button. This property must be set as a client property on a specific button. The value can be:

  • The name of one of the values in SubstanceConstants.Side enum.
  • Array of names of the values in SubstanceConstants.Side enum.
  • A value in SubstanceConstants.Side enum.
  • Array of values in SubstanceConstants.Side enum.


See also


Sample code

import java.awt.FlowLayout;

import javax.swing.*;

import org.jvnet.substance.SubstanceLookAndFeel;
import org.jvnet.substance.utils.SubstanceConstants;

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

    this.setLayout(new FlowLayout());

    JButton buttonA = new JButton("left only");
    // mark button to have open and straight left side
    // using side name
    buttonA.putClientProperty(SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY,
        SubstanceConstants.Side.LEFT.name());
    buttonA.putClientProperty(
        SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY,
        SubstanceConstants.Side.LEFT.name());

    JButton buttonB = new JButton("right only");
    // mark button to have open and straight right side using side constant
    buttonB.putClientProperty(SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY,
        SubstanceConstants.Side.RIGHT);
    buttonB.putClientProperty(
        SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY,
        SubstanceConstants.Side.RIGHT);

    JButton buttonC = new JButton("left+top");
    // mark button to have open and straight left and top sides
    // using array of side names
    buttonC.putClientProperty(SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY,
        new String[] { SubstanceConstants.Side.LEFT.name(),
            SubstanceConstants.Side.TOP.name() });
    buttonC.putClientProperty(
        SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, new String[] {
            SubstanceConstants.Side.LEFT.name(),
            SubstanceConstants.Side.TOP.name() });

    JButton buttonD = new JButton("right+bottom");
    // mark button to have open and straight right and bottom sides
    // using array of side constants
    buttonD.putClientProperty(SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY,
        new SubstanceConstants.Side[] { SubstanceConstants.Side.RIGHT,
            SubstanceConstants.Side.BOTTOM });
    buttonD.putClientProperty(
        SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY,
        new SubstanceConstants.Side[] { SubstanceConstants.Side.RIGHT,
            SubstanceConstants.Side.BOTTOM });

    this.add(buttonA);
    this.add(buttonB);
    this.add(buttonC);
    this.add(buttonD);

    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 ButtonOpenSideProperty().setVisible(true);
      }
    });
  }
}

The screenshot below shows the application frame and buttons with open sides as set in the code above.