Choosing a Color : ColorDialog « SWT « Java Tutorial






  1. SWT provides a class called RGB that stores RGB values.
  2. RGB class holds the data that can represent a color.
  3. SWT provides a class called Color that represents an actual color.
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;

public class ColorCreate {
  public static void main(String[] args) {
    Display display = new Display();

    RGB rgb = new RGB(255, 0, 0); // pure red
    Color color = new Color(display, rgb);

    System.out.println(color.getBlue());

    display.dispose();
  }
}








17.103.ColorDialog
17.103.1.Choosing a Color
17.103.2.Get Selected Color from ColorDialogGet Selected Color from ColorDialog
17.103.3.Customizing the Color Selection DialogCustomizing the Color Selection Dialog
17.103.4.Set Label Background to a color selected in ColorDialogSet Label Background to a color selected in ColorDialog