當前位置: 首頁>>代碼示例>>Java>>正文


Java JColorChooser.setPreviewPanel方法代碼示例

本文整理匯總了Java中javax.swing.JColorChooser.setPreviewPanel方法的典型用法代碼示例。如果您正苦於以下問題:Java JColorChooser.setPreviewPanel方法的具體用法?Java JColorChooser.setPreviewPanel怎麽用?Java JColorChooser.setPreviewPanel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JColorChooser的用法示例。


在下文中一共展示了JColorChooser.setPreviewPanel方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: showDialog

import javax.swing.JColorChooser; //導入方法依賴的package包/類
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();
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:20,代碼來源:ColorSelectionButton.java

示例2: test

import javax.swing.JColorChooser; //導入方法依賴的package包/類
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");
        }
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:27,代碼來源:Test4193384.java

示例3: main

import javax.swing.JColorChooser; //導入方法依賴的package包/類
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()");
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:12,代碼來源:Test4461329.java

示例4: init

import javax.swing.JColorChooser; //導入方法依賴的package包/類
public void init() {
    JColorChooser chooser = new JColorChooser();
    chooser.setPreviewPanel(new JLabel("Text Preview Panel"));
    getContentPane().add(chooser);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:6,代碼來源:Test6977726.java

示例5: init

import javax.swing.JColorChooser; //導入方法依賴的package包/類
public void init() {
    JColorChooser chooser = new JColorChooser();
    chooser.setPreviewPanel(new JPanel());
    getContentPane().add(chooser);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:6,代碼來源:Test4759306.java


注:本文中的javax.swing.JColorChooser.setPreviewPanel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。