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(400, 200);
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[] args) throws 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:
|