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(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 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:
|