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