Java Code Examples for javax.swing.JColorChooser#setPreviewPanel()

The following examples show how to use javax.swing.JColorChooser#setPreviewPanel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ColorSelectionButton.java    From rapidminer-studio with GNU Affero General Public License v3.0 7 votes vote down vote up
private Color showDialog(Component component, String title, Color initialColor) throws HeadlessException {
	final JColorChooser chooser = new JColorChooser(initialColor != null ? initialColor : Color.white);

	// configuring color chooser panel

	chooser.setPreviewPanel(new JPanel());
	if (colorChoosers != null) {
		chooser.setChooserPanels(colorChoosers);
	} else {
		chooser.removeChooserPanel(chooser.getChooserPanels()[0]);
		chooser.removeChooserPanel(chooser.getChooserPanels()[1]);
	}

	// creating dialog
	ColorTracker ok = new ColorTracker(chooser);
	JDialog dialog = JColorChooser.createDialog(component, title, true, chooser, ok, null);
	dialog.setVisible(true); // blocks until user brings dialog down...
	return ok.getColor();
}
 
Example 2
Source File: Test4193384.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static void test(Color[] colors) {
    JLabel label = new JLabel("Preview Panel"); // NON-NLS: simple label

    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");
        }
    }
}
 
Example 3
Source File: Test4193384.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void test(Color[] colors) {
    JLabel label = new JLabel("Preview Panel"); // NON-NLS: simple label

    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");
        }
    }
}
 
Example 4
Source File: Test4193384.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static void test(Color[] colors) {
    JLabel label = new JLabel("Preview Panel"); // NON-NLS: simple label

    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");
        }
    }
}
 
Example 5
Source File: Test4193384.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static void test(Color[] colors) {
    JLabel label = new JLabel("Preview Panel"); // NON-NLS: simple label

    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");
        }
    }
}
 
Example 6
Source File: Test4193384.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void test(Color[] colors) {
    JLabel label = new JLabel("Preview Panel"); // NON-NLS: simple label

    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");
        }
    }
}
 
Example 7
Source File: Test4461329.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    JColorChooser chooser = new JColorChooser();
    if (null == chooser.getPreviewPanel()) {
        throw new Error("Failed: getPreviewPanel() returned null");
    }
    JButton button = new JButton("Color"); // NON-NLS: simple label
    chooser.setPreviewPanel(button);
    if (button != chooser.getPreviewPanel()) {
        throw new Error("Failed in setPreviewPanel()");
    }
}
 
Example 8
Source File: Test4461329.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    JColorChooser chooser = new JColorChooser();
    if (null == chooser.getPreviewPanel()) {
        throw new Error("Failed: getPreviewPanel() returned null");
    }
    JButton button = new JButton("Color"); // NON-NLS: simple label
    chooser.setPreviewPanel(button);
    if (button != chooser.getPreviewPanel()) {
        throw new Error("Failed in setPreviewPanel()");
    }
}
 
Example 9
Source File: Test4461329.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    JColorChooser chooser = new JColorChooser();
    if (null == chooser.getPreviewPanel()) {
        throw new Error("Failed: getPreviewPanel() returned null");
    }
    JButton button = new JButton("Color"); // NON-NLS: simple label
    chooser.setPreviewPanel(button);
    if (button != chooser.getPreviewPanel()) {
        throw new Error("Failed in setPreviewPanel()");
    }
}
 
Example 10
Source File: Test4461329.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    JColorChooser chooser = new JColorChooser();
    if (null == chooser.getPreviewPanel()) {
        throw new Error("Failed: getPreviewPanel() returned null");
    }
    JButton button = new JButton("Color"); // NON-NLS: simple label
    chooser.setPreviewPanel(button);
    if (button != chooser.getPreviewPanel()) {
        throw new Error("Failed in setPreviewPanel()");
    }
}
 
Example 11
Source File: Test4461329.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    JColorChooser chooser = new JColorChooser();
    if (null == chooser.getPreviewPanel()) {
        throw new Error("Failed: getPreviewPanel() returned null");
    }
    JButton button = new JButton("Color"); // NON-NLS: simple label
    chooser.setPreviewPanel(button);
    if (button != chooser.getPreviewPanel()) {
        throw new Error("Failed in setPreviewPanel()");
    }
}
 
Example 12
Source File: Test4759306.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void init() {
    JColorChooser chooser = new JColorChooser();
    chooser.setPreviewPanel(new JPanel());
    getContentPane().add(chooser);
}
 
Example 13
Source File: Test4759306.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void init() {
    JColorChooser chooser = new JColorChooser();
    chooser.setPreviewPanel(new JPanel());
    getContentPane().add(chooser);
}
 
Example 14
Source File: Test6977726.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void init() {
    JColorChooser chooser = new JColorChooser();
    chooser.setPreviewPanel(new JLabel("Text Preview Panel"));
    getContentPane().add(chooser);
}
 
Example 15
Source File: Test6977726.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void init() {
    JColorChooser chooser = new JColorChooser();
    chooser.setPreviewPanel(new JLabel("Text Preview Panel"));
    getContentPane().add(chooser);
}
 
Example 16
Source File: Test4759306.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void init() {
    JColorChooser chooser = new JColorChooser();
    chooser.setPreviewPanel(new JPanel());
    getContentPane().add(chooser);
}
 
Example 17
Source File: Test4759306.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void init() {
    JColorChooser chooser = new JColorChooser();
    chooser.setPreviewPanel(new JPanel());
    getContentPane().add(chooser);
}
 
Example 18
Source File: Test4759306.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public void init() {
    JColorChooser chooser = new JColorChooser();
    chooser.setPreviewPanel(new JPanel());
    getContentPane().add(chooser);
}
 
Example 19
Source File: Test6977726.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void init() {
    JColorChooser chooser = new JColorChooser();
    chooser.setPreviewPanel(new JLabel("Text Preview Panel"));
    getContentPane().add(chooser);
}
 
Example 20
Source File: Test4759306.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void init() {
    JColorChooser chooser = new JColorChooser();
    chooser.setPreviewPanel(new JPanel());
    getContentPane().add(chooser);
}