Search in sources :

Example 16 with JColorChooser

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

the class Test4165217 method main.

public static void main(String[] args) {
    JColorChooser chooser = new JColorChooser();
    chooser.setColor(new Color(new Random().nextInt()));
    Color before = chooser.getColor();
    Color after = copy(chooser).getColor();
    if (!after.equals(before)) {
        throw new Error("color is changed after serialization");
    }
}
Also used : Random(java.util.Random) Color(java.awt.Color) JColorChooser(javax.swing.JColorChooser)

Example 17 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 18 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 19 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 20 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)

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