@Override
public Component getPreview ( final WebLookAndFeelDemo owner )
{
// Default value
final GradientData defaultValue = SettingsManager.getDefaultValue ( GradientData.class );
// Simple color chooser
colorChooser = new WebGradientColorChooser ();
colorChooser.setPreferredWidth ( 350 );
colorChooser.registerSettings ( "GradientColorChooserExample.gradientData", GradientData.class );
// Reset button
final WebButton colored = new WebButton ( loadIcon ( "colored.png" ) );
TooltipManager.setTooltip ( colored, "Various colors" );
colored.addActionListener ( new ActionListener ()
{
@Override
public void actionPerformed ( ActionEvent e )
{
// Simply apply default gradient values
colorChooser.setGradientData ( defaultValue.clone () );
}
} );
// Black & white colors button
final WebButton blackAndWhite = new WebButton ( loadIcon ( "bw.png" ) );
TooltipManager.setTooltip ( blackAndWhite, "Black and white colors" );
blackAndWhite.addActionListener ( new ActionListener ()
{
@Override
public void actionPerformed ( ActionEvent e )
{
// Apply gradient values through SettingsManager
// Notice that component will be automatically updated due to external settings changes!
final GradientData blackAndWhite = new GradientData ();
blackAndWhite.addGradientColorData ( new GradientColorData ( 0f, Color.BLACK ) );
blackAndWhite.addGradientColorData ( new GradientColorData ( 1f, Color.WHITE ) );
SettingsManager.set ( "GradientColorChooserExample.gradientData", blackAndWhite );
}
} );
final WebButtonGroup buttonGroup = new WebButtonGroup ( colored, blackAndWhite );