Example usage for javax.swing JColorChooser createDialog

List of usage examples for javax.swing JColorChooser createDialog

Introduction

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

Prototype

public static JDialog createDialog(Component c, String title, boolean modal, JColorChooser chooserPane,
        ActionListener okListener, ActionListener cancelListener) throws HeadlessException 

Source Link

Document

Creates and returns a new dialog containing the specified ColorChooser pane along with "OK", "Cancel", and "Reset" buttons.

Usage

From source file:TableDialogEditDemo.java

public ColorEditor() {
    //Set up the editor (from the table's point of view),
    //which is a button.
    //This button brings up the color chooser dialog,
    //which is the editor from the user's point of view.
    button = new JButton();
    button.setActionCommand(EDIT);/*from w  ww . j a va 2 s .c  o m*/
    button.addActionListener(this);
    button.setBorderPainted(false);

    //Set up the dialog that the button brings up.
    colorChooser = new JColorChooser();
    dialog = JColorChooser.createDialog(button, "Pick a Color", true, //modal
            colorChooser, this, //OK button handler
            null); //no CANCEL button handler
}

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);//from   w  ww. j a v  a  2 s.c  o m

    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();
}

From source file:org.forester.archaeopteryx.TreePanel.java

final private void colorSubtree(final PhylogenyNode node) {
    Color intitial_color = null;/*from   w  w w .  jav a2 s .c om*/
    if (getControlPanel().isColorBranches() && (PhylogenyMethods.getBranchColorValue(node) != null)
            && (((!node.isRoot() && (node.getParent().getNumberOfDescendants() < 3))) || (node.isRoot()))) {
        intitial_color = PhylogenyMethods.getBranchColorValue(node);
    } else {
        intitial_color = getTreeColorSet().getBranchColor();
    }
    _color_chooser.setColor(intitial_color);
    _color_chooser.setPreviewPanel(new JPanel());
    final JDialog dialog = JColorChooser.createDialog(this, "Subtree colorization", true, _color_chooser,
            new SubtreeColorizationActionListener(_color_chooser, node), null);
    dialog.setVisible(true);
}

From source file:techtonic.Onview.java

public ColorEditors() {
    button = new JButton();
    button.setActionCommand(EDIT);//from  ww  w  .  j  a v  a2 s .  c om
    button.addActionListener(this);
    button.setBorderPainted(false);
    colorChooser = new JColorChooser();
    dialog = JColorChooser.createDialog(button, "choose color", true, //modal
            colorChooser, this, null);
}