Substance client properties

View all API methods.

View all client properties.


Client property name

SubstanceLookAndFeel.TITLE_PAINTER_PROPERTY

Description

Property name for specifying title painter. This property is used both as a JVM flag and as a client property that can be set on a specific root pane / internal frame.

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


See also


Sample code

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import org.jvnet.substance.SubstanceLookAndFeel;
import org.jvnet.substance.title.Glass3DTitlePainter;
import org.jvnet.substance.title.RandomCubesTitlePainter;

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

    this.setLayout(new FlowLayout());

    JButton buttonClassic = new JButton("Classic");
    buttonClassic.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        // set root pane to have custom title painter based
        // on title painter class name
        getRootPane().putClientProperty(
            SubstanceLookAndFeel.TITLE_PAINTER_PROPERTY,
            "org.jvnet.substance.title.ClassicTitlePainter");
        repaint();
      }
    });
    JButton buttonGlass3D = new JButton("Glass3D");
    buttonGlass3D.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        // set root pane to have custom title painter based
        // on title painter instance
        getRootPane().putClientProperty(
            SubstanceLookAndFeel.TITLE_PAINTER_PROPERTY,
            new Glass3DTitlePainter());
        repaint();
      }
    });
    JButton buttonRandomCubes = new JButton("Random Cubes");
    buttonRandomCubes.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        getRootPane().putClientProperty(
            SubstanceLookAndFeel.TITLE_PAINTER_PROPERTY,
            new RandomCubesTitlePainter());
        repaint();
      }
    });

    this.add(buttonClassic);
    this.add(buttonGlass3D);
    this.add(buttonRandomCubes);

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

The screenshot below shows this property set to an instance of SubstanceTitlePainter:

The screenshot below shows this property set to a fully-qualified name of the title painter class: