Substance client properties

View all API methods.

View all client properties.


Client property name

SubstanceLookAndFeel.GRADIENT_PAINTER_PROPERTY

Description

Property name for specifying gradient painter. This property is used both as a JVM flag and as a client property that can be set on a specific button.

For the JVM flag, the value should be fully-qualified name of the gradient painter class. This class must have a default (no-argument) constructor. For the client property, the value can be either a fully-qualified class name as above or an instance of SubstanceGradientPainter.


See also


Sample code

import java.awt.FlowLayout;

import javax.swing.*;

import org.jvnet.substance.SubstanceLookAndFeel;
import org.jvnet.substance.painter.GradientWaveGradientPainter;

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

    this.setLayout(new FlowLayout());

    JButton buttonA = new JButton("default");

    JButton buttonB = new JButton("by name");
    // set gradient painter on the button by the gradient class name
    buttonB.putClientProperty(
        SubstanceLookAndFeel.GRADIENT_PAINTER_PROPERTY,
        "org.jvnet.substance.painter.SpecularGradientPainter");

    JButton buttonC = new JButton("by instance");
    // set gradient painter on the button by the gradient instance
    buttonC.putClientProperty(
        SubstanceLookAndFeel.GRADIENT_PAINTER_PROPERTY,
        new GradientWaveGradientPainter());

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

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

The screenshot below shows application frame in which the middle and the right buttons have custom gradient painters installed. The mouse is over the right button to illustrate the Wave painter: