Substance client properties

View all API methods.

View all client properties.


Client property name

SubstanceLookAndFeel.CORNER_RADIUS

Description

Client property name for specifying the corner radius for buttons. Currently, this property is respected only on toolbar buttons. This property can be set either as a client property on a specific toolbar button, a client property on a specific toolbar (will hold for all buttons in the toolbar) or as a global setting on UIManager. The value should be a Float instance.


See also


Sample code

import java.awt.BorderLayout;

import javax.swing.*;

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

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

    this.setLayout(new BorderLayout());

    JToolBar toolBar = new JToolBar("");
    toolBar.add(new JLabel("Sample toolbar"));
    toolBar.add(new JSeparator(SwingConstants.VERTICAL));

    JToggleButton buttonDefault = new JToggleButton("radius default");
    buttonDefault.setSelected(true);
    toolBar.add(buttonDefault);

    JToggleButton button1 = new JToggleButton("radius 5");
    // set corner radius to 5 pixels
    button1.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, Float
        .valueOf(5.0f));
    button1.setSelected(true);
    toolBar.add(button1);

    JToggleButton button2 = new JToggleButton("radius 0");
    // set corner radius to 0 pixels (perfect rectangle)
    button2.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, Float
        .valueOf(0.0f));
    button2.setSelected(true);
    toolBar.add(button2);

    this.add(toolBar, BorderLayout.NORTH);

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

The screenshot below shows application frame with three tollbar buttons. The left button has default radius, while the middle and the right buttons have custom radius.