ColorDialogCreateGetColor.java Source code

Java tutorial

Introduction

Here is the source code for ColorDialogCreateGetColor.java

Source

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 ColorDialogCreateGetColor {
    public static void main(String[] args) {
        Display display = new Display();
        Shell shell = new Shell(display);

        ColorDialog dlg = new ColorDialog(shell);
        RGB rgb = dlg.open();
        if (rgb != null) {
            Color color = new Color(shell.getDisplay(), rgb);

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

            color.dispose();
        }

        display.dispose();
    }
}