Substance client properties

View all API methods.

View all client properties.


Client property name

SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY

Description

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

  • A value in SubstanceConstants.Side enum.
  • Set of values in SubstanceConstants.Side enum.

Note that SubstanceButtonShaper implementations are not required to respect this property. The default StandardButtonShaper and ClassicButtonShaper respect this property.


See also


Sample code

import java.awt.FlowLayout;
import java.util.EnumSet;

import javax.swing.*;

import org.pushingpixels.substance.api.SubstanceConstants;
import org.pushingpixels.substance.api.SubstanceLookAndFeel;
import org.pushingpixels.substance.api.skin.BusinessBlackSteelSkin;

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

    this.setLayout(new FlowLayout());

    JButton buttonA = new JButton("left only");
    // Mark button to have straight left side
    // using side constant
    buttonA.putClientProperty(SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY,
        SubstanceConstants.Side.LEFT);

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

    JButton buttonC = new JButton("left+top");
    // Mark button to have straight left and top sides
    // using set of side constants
    buttonC.putClientProperty(SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY,
        EnumSet.of(SubstanceConstants.Side.LEFT,
            SubstanceConstants.Side.TOP));

    JButton buttonD = new JButton("right+bottom");
    // Mark button to have straight right and bottom sides
    // using set of side constants
    buttonD.putClientProperty(SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY,
        EnumSet.of(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.
   */
  public static void main(String[] args) {
    JFrame.setDefaultLookAndFeelDecorated(true);
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin());
        new ButtonSideProperty().setVisible(true);
      }
    });
  }
}

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