Example usage for javax.swing JColorChooser setColor

List of usage examples for javax.swing JColorChooser setColor

Introduction

In this page you can find the example usage for javax.swing JColorChooser setColor.

Prototype

public void setColor(int c) 

Source Link

Document

Sets the current color of the color chooser to the specified color.

Usage

From source file:Main.java

public static void main(String[] argv) {
    JColorChooser chooser = new JColorChooser();

    // Set the selected color
    chooser.setColor(Color.red);

    // Get current selected color
    Color color = chooser.getColor();

}

From source file:freemind.controller.Controller.java

public static Color showCommonJColorChooserDialog(Component component, String title, Color initialColor)
        throws HeadlessException {

    final JColorChooser pane = getCommonJColorChooser();
    pane.setColor(initialColor);

    ColorTracker ok = new ColorTracker(pane);
    JDialog dialog = JColorChooser.createDialog(component, title, true, pane, ok, null);
    dialog.addWindowListener(new Closer());
    dialog.addComponentListener(new DisposeOnClose());

    dialog.show(); // blocks until user brings dialog down...

    return ok.getColor();
}