当前位置: 首页>>代码示例>>Java>>正文


Java JColorChooser.setColor方法代码示例

本文整理汇总了Java中javax.swing.JColorChooser.setColor方法的典型用法代码示例。如果您正苦于以下问题:Java JColorChooser.setColor方法的具体用法?Java JColorChooser.setColor怎么用?Java JColorChooser.setColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JColorChooser的用法示例。


在下文中一共展示了JColorChooser.setColor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: actionPerformed

import javax.swing.JColorChooser; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent ae) {
    
	if (ae.getSource()==this.button) {
        //The user has clicked the cell, so bring up the dialog.
        button.setBackground(currentColor);
       
        //Set up the dialog that the button brings up.
        colorChooser = new JColorChooser();
        colorChooser.setColor(currentColor);
        JDialog dialog = JColorChooser.createDialog(button, "Pick a Color", true, colorChooser, this,  null); 
        dialog.setVisible(true);
        // --- From here: user action in the dialog ---
        fireEditingStopped();
        
    } else { //User pressed dialog's "OK" button.
        currentColor = colorChooser.getColor();
    }
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:20,代码来源:TableCellEditor4Color.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: NbColorChooser

import javax.swing.JColorChooser; //导入方法依赖的package包/类
/** Creates new <code>NbColorChooser</code>. */
public NbColorChooser (final ColorEditor editor,
                       final JColorChooser chooser) {
    this.editor = editor;
    selectionModel = chooser.getSelectionModel();
    setLayout (new BorderLayout ());
    add (chooser, BorderLayout.CENTER);
    chooser.setColor ((Color)editor.getValue ());
    selectionModel.addChangeListener (this);
    
    getAccessibleContext().setAccessibleDescription(getString("ACSD_CustomColorEditor"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:ColorEditor.java

示例4: main

import javax.swing.JColorChooser; //导入方法依赖的package包/类
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");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:Test4165217.java


注:本文中的javax.swing.JColorChooser.setColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。