Search in sources :

Example 26 with JColorChooser

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

the class Test4177735 method main.

public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });
    JDialog dialog = show(chooser);
    pause(DELAY);
    dialog.dispose();
    pause(DELAY);
    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
Also used : AbstractColorChooserPanel(javax.swing.colorchooser.AbstractColorChooserPanel) JColorChooser(javax.swing.JColorChooser) JDialog(javax.swing.JDialog)

Example 27 with JColorChooser

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

the class Test4193384 method test.

private static void test(Color[] colors) {
    // NON-NLS: simple label
    JLabel label = new JLabel("Preview Panel");
    JColorChooser chooser = new JColorChooser();
    chooser.setPreviewPanel(label);
    float[] hsb = new float[3];
    for (int i = 0; i < colors.length; i++) {
        Color color = colors[i];
        // Make sure sure that there wasn't a regression
        // in java.awt.Color and the conversion methods
        Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsb);
        if (!color.equals(Color.getHSBColor(hsb[0], hsb[1], hsb[2]))) {
            throw new Error("color conversion is failed");
        }
        // 4193384 regression test
        if (!color.equals(new JColorChooser(color).getColor())) {
            throw new Error("constructor sets incorrect initial color");
        }
        // 4200976 regression test
        chooser.setColor(color);
        if (!color.equals(label.getForeground())) {
            throw new Error("a custom preview panel doesn't handle colors");
        }
    }
}
Also used : Color(java.awt.Color) JLabel(javax.swing.JLabel) JColorChooser(javax.swing.JColorChooser)

Example 28 with JColorChooser

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

the class Test4222508 method init.

@Override
public void init() {
    this.chooser = new JColorChooser();
    this.checkbox = new JCheckBox("Enable the color chooser below", true);
    this.checkbox.addItemListener(this);
    add(BorderLayout.NORTH, this.checkbox);
    add(BorderLayout.CENTER, this.chooser);
}
Also used : JCheckBox(javax.swing.JCheckBox) JColorChooser(javax.swing.JColorChooser)

Example 29 with JColorChooser

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

the class Test4234761 method main.

public static void main(String[] args) {
    JColorChooser chooser = new JColorChooser(COLOR);
    JDialog dialog = Test4177735.show(chooser);
    PropertyChangeListener listener = new Test4234761();
    // NON-NLS: property name
    chooser.addPropertyChangeListener("color", listener);
    JTabbedPane tabbedPane = (JTabbedPane) chooser.getComponent(0);
    // HSB tab index
    tabbedPane.setSelectedIndex(1);
    if (!chooser.getColor().equals(COLOR)) {
        listener.propertyChange(null);
    }
    dialog.dispose();
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) JTabbedPane(javax.swing.JTabbedPane) JColorChooser(javax.swing.JColorChooser) JDialog(javax.swing.JDialog)

Example 30 with JColorChooser

use of javax.swing.JColorChooser in project CodenameOne by codenameone.

the class AddThemeEntry method pickColor.

private void pickColor(final JTextComponent colorText) {
    int color = Integer.decode("0x" + colorText.getText());
    if (colorChooser == null) {
        colorChooser = new JColorChooser();
    }
    colorChooser.setColor(color);
    JDialog dlg = JColorChooser.createDialog(this, "Pick color", true, colorChooser, new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            int i = colorChooser.getColor().getRGB() & 0xffffff;
            colorText.setText(Integer.toHexString(i));
            // themeHash.put(getKey(), getValue());
            updateThemeHashtable(themeHash);
            refreshTheme(themeHash);
        }
    }, null);
    dlg.setLocationByPlatform(true);
    dlg.pack();
    dlg.setVisible(true);
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JColorChooser(javax.swing.JColorChooser) JDialog(javax.swing.JDialog)

Aggregations

JColorChooser (javax.swing.JColorChooser)35 JDialog (javax.swing.JDialog)14 ActionEvent (java.awt.event.ActionEvent)10 ActionListener (java.awt.event.ActionListener)10 JButton (javax.swing.JButton)10 JLabel (javax.swing.JLabel)9 JPanel (javax.swing.JPanel)9 Color (java.awt.Color)7 JFrame (javax.swing.JFrame)7 AbstractColorChooserPanel (javax.swing.colorchooser.AbstractColorChooserPanel)7 BorderLayout (java.awt.BorderLayout)5 Component (java.awt.Component)5 JTextField (javax.swing.JTextField)5 JCheckBox (javax.swing.JCheckBox)4 JOptionPane (javax.swing.JOptionPane)4 JRadioButton (javax.swing.JRadioButton)4 JScrollPane (javax.swing.JScrollPane)4 Frame (java.awt.Frame)3 WindowAdapter (java.awt.event.WindowAdapter)3 WindowEvent (java.awt.event.WindowEvent)3