Search in sources :

Example 6 with JColorChooser

use of javax.swing.JColorChooser in project jdk8u_jdk by JetBrains.

the class Test6707406 method test.

private static void test() {
    JColorChooser chooser = new JColorChooser();
    chooser.getUI().uninstallUI(chooser);
    new Test6707406().installUI(chooser);
    chooser.getSelectionModel().setSelectedColor(Color.BLUE);
}
Also used : JColorChooser(javax.swing.JColorChooser)

Example 7 with JColorChooser

use of javax.swing.JColorChooser in project jdk8u_jdk by JetBrains.

the class Test6977726 method init.

public void init() {
    JColorChooser chooser = new JColorChooser();
    chooser.setPreviewPanel(new JLabel("Text Preview Panel"));
    getContentPane().add(chooser);
}
Also used : JLabel(javax.swing.JLabel) JColorChooser(javax.swing.JColorChooser)

Example 8 with JColorChooser

use of javax.swing.JColorChooser in project jdk8u_jdk by JetBrains.

the class Test6348456 method init.

@Override
public void init() {
    JButton button = new JButton("Swap models");
    button.addActionListener(this);
    this.chooser = new JColorChooser(Color.RED);
    this.chooser.setSelectionModel(WHITE);
    add(BorderLayout.NORTH, button);
    add(BorderLayout.CENTER, this.chooser);
}
Also used : JButton(javax.swing.JButton) JColorChooser(javax.swing.JColorChooser)

Example 9 with JColorChooser

use of javax.swing.JColorChooser in project jdk8u_jdk by JetBrains.

the class Test7194184 method run.

public void run() {
    String title = getClass().getName();
    frame = new JFrame(title);
    colorChooser = new JColorChooser();
    frame.add(colorChooser);
    frame.pack();
    frame.setVisible(true);
}
Also used : JFrame(javax.swing.JFrame) JColorChooser(javax.swing.JColorChooser)

Example 10 with JColorChooser

use of javax.swing.JColorChooser in project processdash by dtuma.

the class ColorCellEditor method setUpColorEditor.

//Set up the editor for the Color cells.
public static void setUpColorEditor(JTable table) {
    //First, set up the button that brings up the dialog.
    final JButton button = new JButton("") {

        public void setText(String s) {
        //Button never shows text -- only color.
        }
    };
    button.setBackground(Color.white);
    button.setBorderPainted(false);
    button.setMargin(new Insets(0, 0, 0, 0));
    //Now create an editor to encapsulate the button, and
    //set it up as the editor for all Color cells.
    final ColorCellEditor colorEditor = new ColorCellEditor(button);
    table.setDefaultEditor(Color.class, colorEditor);
    //Set up the dialog that the button brings up.
    final JColorChooser colorChooser = new JColorChooser();
    ActionListener okListener = new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            colorEditor.currentColor = colorChooser.getColor();
        }
    };
    final JDialog dialog = JColorChooser.createDialog(button, "Pick a Color", true, colorChooser, okListener, null);
    //Here's the code that brings up the dialog.
    button.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            button.setBackground(colorEditor.currentColor);
            colorChooser.setColor(colorEditor.currentColor);
            //Without the following line, the dialog comes up
            //in the middle of the screen.
            //dialog.setLocationRelativeTo(button);
            dialog.setVisible(true);
        }
    });
}
Also used : Insets(java.awt.Insets) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JColorChooser(javax.swing.JColorChooser) JDialog(javax.swing.JDialog)

Aggregations

JColorChooser (javax.swing.JColorChooser)21 JDialog (javax.swing.JDialog)7 JLabel (javax.swing.JLabel)6 JButton (javax.swing.JButton)5 Component (java.awt.Component)4 JFrame (javax.swing.JFrame)4 JPanel (javax.swing.JPanel)4 JCheckBox (javax.swing.JCheckBox)3 AbstractColorChooserPanel (javax.swing.colorchooser.AbstractColorChooserPanel)3 Color (java.awt.Color)2 Frame (java.awt.Frame)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 ArrayList (java.util.ArrayList)2 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)2 JComponent (javax.swing.JComponent)2 JDesktopPane (javax.swing.JDesktopPane)2 JEditorPane (javax.swing.JEditorPane)2 JFileChooser (javax.swing.JFileChooser)2 JFormattedTextField (javax.swing.JFormattedTextField)2