// Hue
final WebLabel hueButton = new WebLabel ( "H:" );
hueButton.setDrawShade ( true );
colorsPanel.add ( hueButton, "0,0" );
hueField = new WebTextField ();
colorsPanel.add ( hueField, "2,0" );
final WebLabel hueSuffix = new WebLabel ( "°" );
hueSuffix.setDrawShade ( true );
colorsPanel.add ( hueSuffix, "4,0" );
// Saturation
final WebLabel saturationButton = new WebLabel ( "S:" );
saturationButton.setDrawShade ( true );
colorsPanel.add ( saturationButton, "0,2" );
saturationField = new WebTextField ();
colorsPanel.add ( saturationField, "2,2" );
final WebLabel saturationSuffix = new WebLabel ( "%" );
saturationSuffix.setDrawShade ( true );
colorsPanel.add ( saturationSuffix, "4,2" );
// Brightness
final WebLabel brightnessButton = new WebLabel ( "B:" );
brightnessButton.setDrawShade ( true );
colorsPanel.add ( brightnessButton, "0,4" );
brightnessField = new WebTextField ();
colorsPanel.add ( brightnessField, "2,4" );
final WebLabel brightnessSuffix = new WebLabel ( "%" );
brightnessSuffix.setDrawShade ( true );
colorsPanel.add ( brightnessSuffix, "4,4" );
final CaretListener hsbListener = new CaretListener ()
{
@Override
public void caretUpdate ( final CaretEvent e )
{
if ( !adjustingText )
{
palette.removeChangeListener ( paletteListener );
try
{
final float h = ( float ) Integer.parseInt ( hueField.getText () ) / 360;
final float s = ( float ) Integer.parseInt ( saturationField.getText () ) / 100;
final float b = ( float ) Integer.parseInt ( brightnessField.getText () ) / 100;
color = new HSBColor ( h, s, b ).getColor ();
updateColors ( color, UpdateSource.hsbField );
}
catch ( final Throwable ex )
{
//
}
palette.addChangeListener ( paletteListener );
}
}
};
hueField.addCaretListener ( hsbListener );
saturationField.addCaretListener ( hsbListener );
brightnessField.addCaretListener ( hsbListener );
colorsPanel.add ( new WebSeparator ( WebSeparator.HORIZONTAL ), "0,6,4,6" );
final WebLabel redButton = new WebLabel ( "R:" );
redButton.setDrawShade ( true );
colorsPanel.add ( redButton, "0,8" );
redField = new WebTextField ();
redField.setColumns ( 3 );
colorsPanel.add ( redField, "2,8" );
final WebLabel greenButton = new WebLabel ( "G:" );
greenButton.setDrawShade ( true );
colorsPanel.add ( greenButton, "0,10" );
greenField = new WebTextField ();
greenField.setColumns ( 3 );
colorsPanel.add ( greenField, "2,10" );
final WebLabel blueButton = new WebLabel ( "B:" );
blueButton.setDrawShade ( true );
colorsPanel.add ( blueButton, "0,12" );
blueField = new WebTextField ();
blueField.setColumns ( 3 );
colorsPanel.add ( blueField, "2,12" );
final CaretListener rgbListener = new CaretListener ()
{
@Override
public void caretUpdate ( final CaretEvent e )
{
if ( !adjustingText )
{
palette.removeChangeListener ( paletteListener );
try
{
final int r = Integer.parseInt ( redField.getText () );
final int g = Integer.parseInt ( greenField.getText () );
final int b = Integer.parseInt ( blueField.getText () );
color = new Color ( r, g, b );
updateColors ( color, UpdateSource.rgbField );
}
catch ( final Throwable ex )
{
//
}
palette.addChangeListener ( paletteListener );
}
}
};
redField.addCaretListener ( rgbListener );
greenField.addCaretListener ( rgbListener );
blueField.addCaretListener ( rgbListener );
infoPanel.add ( new WebSeparator ( WebSeparator.HORIZONTAL ), "0,9,2,9" );
final WebLabel hexLabel = new WebLabel ( "#" );
hexLabel.setDrawShade ( true );
infoPanel.add ( hexLabel, "0,11" );
hexColor = new WebTextField ();
updateHexField ( color );
final CaretListener hexListener = new CaretListener ()
{
@Override
public void caretUpdate ( final CaretEvent e )