Customizing the Color Selection Dialog : ColorDialog « SWT « Java Tutorial






Customizing the Color Selection Dialog
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.ColorDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

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

    ColorDialog dlg = new ColorDialog(shell);
    dlg.setRGB(new RGB(0, 0, 255));
    RGB rgb = dlg.open();
    if (rgb != null) {
      Color color = new Color(shell.getDisplay(), rgb);
      System.out.println(color.getRGB());
      
      color.dispose();
    }

    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