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


Java JColorChooser类代码示例

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


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

示例1: ColorValueCellEditor

import javax.swing.JColorChooser; //导入依赖的package包/类
public ColorValueCellEditor(final ParameterTypeColor type) {
	this.type = type;
	button = new JButton("Choose Color...");
	button.setToolTipText(type.getDescription());
	button.setIconTextGap(6);
	button.addActionListener(new ActionListener() {

		@Override
		public void actionPerformed(ActionEvent e) {
			Color newColor = JColorChooser.showDialog(RapidMinerGUI.getMainFrame(), "Choose Color for " + type.getKey(),
					((ColorIcon) button.getIcon()).getColor());
			if (newColor != null) {
				setEditorColor(newColor);
			}
			fireEditingStopped();
		}
	});
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:19,代码来源:ColorValueCellEditor.java

示例2: jPanelStarColourMouseClicked

import javax.swing.JColorChooser; //导入依赖的package包/类
private void jPanelStarColourMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanelStarColourMouseClicked
    Color initialBackground = new Color(255, 255, 0);
    Color background = JColorChooser.showDialog(null, "Set Colour",
            initialBackground);
    if ((background != null) && (background != jPanelStarColour.getBackground())) {
        stopStarEffect();
        gKeyboard.getEffect().StarColour = IOOperations.getHexStringFromColour(background);
        gKeyboard.setAllKeys(gKeyboard.getEffect().SkyColour, true);
        jPanelStarColour.setBackground(background);
        jPanelColour115.setBackground(background);
        jLayeredPane1.moveToBack(jPanelColour115);
        jPanelColour116.setBackground(background);
        jLayeredPane1.moveToBack(jPanelColour116);
        gKeyboard.setGroupKeys("logo", gKeyboard.getEffect().StarColour, true);
        startStarEffect(gKeyboard.getEffect().StarColour, gKeyboard.getEffect().SkyColour);
    }
}
 
开发者ID:MohamadSaada,项目名称:LogiGSK,代码行数:18,代码来源:G910SparkUSQWERTY.java

示例3: ColorComboBox

import javax.swing.JColorChooser; //导入依赖的package包/类
/** Creates a new instance of ColorChooser */
public ColorComboBox() {
    super(content);
    setRenderer(new Renderer());
    setEditable(true);
    setEditor(new Renderer());
    setSelectedItem(new Value(null, null));
    addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            if (getSelectedItem() == CUSTOM_COLOR) {
                Color c = JColorChooser.showDialog(
                        SwingUtilities.getAncestorOfClass
                        (Dialog.class, ColorComboBox.this),
                        loc("SelectColor"), // NOI18N
                        null
                        );
                setColor(c);
            }
            ColorComboBox.this.firePropertyChange(PROP_COLOR, null, null);
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:SplashUISupport.java

示例4: getStaticChooser

import javax.swing.JColorChooser; //导入依赖的package包/类
/** Gets <code>staticChooser</code> instance. */
public static JColorChooser getStaticChooser(ColorEditor ce) {
    JColorChooser staticChooser = new JColorChooser(new SuperColorSelectionModel())
                        {
                            public void setColor (Color c) {
                                if (c == null) return;
                                super.setColor (c);
                            }
                        };
        staticChooser.addChooserPanel (
            new NbColorChooserPanel (AWT_PALETTE, getAWTColorNames(), awtColors,
                                     getString ("CTL_AWTPalette"), ce)
        );
        initSwingConstants();
        staticChooser.addChooserPanel (
            new NbColorChooserPanel (SWING_PALETTE, swingColorNames, swingColors,
                                     getString ("CTL_SwingPalette"), ce)
        );
        staticChooser.addChooserPanel (
            new NbColorChooserPanel (SYSTEM_PALETTE, getSystemColorNames(), systemColors,
                                     getString ("CTL_SystemPalette"), ce)
        );
    return staticChooser;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ColorEditor.java

示例5: main

import javax.swing.JColorChooser; //导入依赖的package包/类
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JPanel panel = new JPanel();
            JColorChooser colorChooser = new JColorChooser();
            colorChooser.setDragEnabled(true);
            panel.setBorder(BorderFactory.createTitledBorder("JColorChoosers"));
            panel.add(colorChooser);
            frame.setContentPane(panel);
            frame.pack();
            frame.setVisible(true);
        }
    });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:JColorChooserDnDTest.java

示例6: actionPerformed

import javax.swing.JColorChooser; //导入依赖的package包/类
public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    if (CMD_DIALOG.equals(command)) {
        JDialog dialog = new JDialog(this.frame, "Dialog"); // NON-NLS: dialog title
        dialog.setLocation(200, 0);
        show(dialog, CMD_CHOOSER);
    }
    else if (CMD_CHOOSER.equals(command)) {
        Object source = event.getSource();
        Component component = (source instanceof Component)
                ? (Component) source
                : null;

        JColorChooser.showDialog(component, "ColorChooser", Color.BLUE); // NON-NLS: title
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:Test4759934.java

示例7: jPanelBreathingColourMouseClicked

import javax.swing.JColorChooser; //导入依赖的package包/类
private void jPanelBreathingColourMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanelBreathingColourMouseClicked
    Color initialBackground = new Color(255, 0, 255);
    Color background = JColorChooser.showDialog(null, "Set Colour",
        initialBackground);
    if ((background != null) && (background != jPanelBreathingColour.getBackground())) {
        jPanelBreathingColour.setBackground(background);
        if (gKeyboard.getEffect() != null) {
            if (breathingThread != null) {
                breathingThread.terminate();
                breathingThread = null;
            }
            gKeyboard.getEffect().BreathingSpeed = getSpeedFromSlider(Effects.Type.Breathing, jSliderBreathingEffectSpeed.getValue());
            gKeyboard.getEffect().BreathingColour = IOOperations.getHexStringFromColour(jPanelBreathingColour.getBackground());
            breathingThread = new VirtualKeyboardBreathingThread();
            breathingThread.setKeyboardJpanels(getKeyboardJPanels(), jLayeredPane1);
            breathingThread.setSpeed(gKeyboard.getEffect().BreathingSpeed);
            breathingThread.setBreathingColour(gKeyboard.getEffect().BreathingColour);
            gKeyboard.setFXBreathing(gKeyboard.getEffect().BreathingColour, gKeyboard.getEffect().BreathingSpeed);
            breathingThread.start();
        }
    }
}
 
开发者ID:MohamadSaada,项目名称:LogiGSK,代码行数:23,代码来源:G810SpectrumUSQWERTY.java

示例8: ColorChooserPanel

import javax.swing.JColorChooser; //导入依赖的package包/类
/**
 * The constructor to use.
 *
 * @param freeColClient The top level component that holds all
 *     other components.
 * @param l The ActionListener for the OK and cancel buttons.
 */
public ColorChooserPanel(FreeColClient freeColClient, ActionListener l) {
    super(freeColClient, new MigLayout("", "", ""));

    this.colorChooser = new JColorChooser();
    add(this.colorChooser);

    add(okButton, "newline 20, split 2, tag ok");
    okButton.addActionListener(l);

    JButton cancelButton = Utility.localizedButton("cancel");
    add(cancelButton, "tag cancel");
    cancelButton.setActionCommand(CANCEL);
    cancelButton.addActionListener(l);
    setCancelComponent(cancelButton);

    setOpaque(true);
    setSize(getPreferredSize());
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:26,代码来源:ColorChooserPanel.java

示例9: reset

import javax.swing.JColorChooser; //导入依赖的package包/类
public static void reset() {
    add(Component.class, JavaElement.class);
    add(JList.class, JListJavaElement.class);
    add(JTabbedPane.class, JTabbedPaneJavaElement.class);
    add(JComboBox.class, JComboBoxJavaElement.class);
    add(JTable.class, JTableJavaElement.class);
    add(JTableHeader.class, JTableHeaderJavaElement.class);
    add(JTree.class, JTreeJavaElement.class);
    add(JToggleButton.class, JToggleButtonJavaElement.class);
    add(JSpinner.class, JSpinnerJavaElement.class);
    add(JProgressBar.class, JProgressBarJavaElement.class);
    add(JSplitPane.class, JSplitPaneJavaElement.class);
    add(JTextComponent.class, JTextComponentJavaElement.class);
    add(EditorContainer.class, JTreeEditingContainerJavaElement.class);
    add(JEditorPane.class, JEditorPaneJavaElement.class);
    add(JMenuItem.class, JMenuItemJavaElement.class);
    add(JSlider.class, JSliderJavaElement.class);
    add(JSpinner.class, JSpinnerJavaElement.class);
    add(DefaultEditor.class, DefaultEditorJavaElement.class);
    add(JColorChooser.class, JColorChooserJavaElement.class);
    add(JFileChooser.class, JFileChooserJavaElement.class);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:23,代码来源:JavaElementFactory.java

示例10: reset

import javax.swing.JColorChooser; //导入依赖的package包/类
public static void reset() {
    entries.clear();
    add(Component.class, RUnknownComponent.class);
    add(Window.class, RWindow.class);
    add(JTable.class, RTable.class);
    add(JTableHeader.class, RTableHeader.class);
    add(AbstractButton.class, RAbstractButton.class);
    add(JToggleButton.class, RToggleButton.class);
    add(JComboBox.class, RComboBox.class);
    add(JTextComponent.class, RTextComponent.class);
    add(JTree.class, RTree.class);
    add(JList.class, RList.class);
    add(JTabbedPane.class, RTabbedPane.class);
    add(JMenuItem.class, RMenuItem.class);
    add(JSlider.class, RSlider.class);
    add(JProgressBar.class, RProgressBar.class);
    add(JSpinner.class, RSpinner.class);
    add(DefaultEditor.class, RDefaultEditor.class);
    add(JColorChooser.class, RColorChooser.class);
    add(JSplitPane.class, RSplitPane.class);
    add(BasicSplitPaneDivider.class, RSplitPane.class);
    add(JFileChooser.class, RFileChooser.class);
    add(JEditorPane.class, REditorPane.class);
    add(JLabel.class, RLabel.class);
    add(JScrollBar.class, RIgnoreComponent.class);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:27,代码来源:RComponentFactory.java

示例11: setColor

import javax.swing.JColorChooser; //导入依赖的package包/类
public static void setColor(String inTarget) {

        if (inTarget.equals(BACKGROUND)) {
            Color backgroundColor = JColorChooser.showDialog(null,
                "DataBaseManagerSwing Choose Background Color",
                fOwner.txtResult.getBackground());

            if (backgroundColor != null) {
                bgColorButton.setBackground(backgroundColor);
                fOwner.txtCommand.setBackground(backgroundColor);
                fOwner.txtResult.setBackground(backgroundColor);
            }
        } else {
            Color foregroundColor = JColorChooser.showDialog(null,
                "DataBaseManagerSwing Choose Foreground Color",
                fOwner.txtResult.getForeground());

            if (foregroundColor != null) {
                fgColorButton.setBackground(foregroundColor);
                fOwner.txtCommand.setForeground(foregroundColor);
                fOwner.txtResult.setForeground(foregroundColor);
            }
        }
    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:FontDialogSwing.java

示例12: ColorEditor

import javax.swing.JColorChooser; //导入依赖的package包/类
public ColorEditor() {
    // Set up the editor (from the table's point of view),
    // which is a button.
    // This button brings up the color chooser dialog,
    // which is the editor from the user's point of view.
    button = new JButton();
    button.setActionCommand(EDIT);
    button.addActionListener(this);
    button.setBorderPainted(false);

    // Set up the dialog that the button brings up.
    colorChooser = new JColorChooser();
    dialog = JColorChooser.createDialog(button, "Pick a Color", true, // modal
            colorChooser, this, // OK button handler
            null); // no CANCEL button handler
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:17,代码来源:ColorEditor.java

示例13: ColorCellEditor

import javax.swing.JColorChooser; //导入依赖的package包/类
/**
 * Constructor.
 */
public ColorCellEditor() {
    button = new JButton() {
        @Override
        public void paintComponent(Graphics g) {
            // When the buttons are pressed they are redrawn with the default
            // background color but not what we want.
            g.setColor(getBackground());
            g.fillRect(0, 0, getWidth(), getHeight());
        }
    };
    
    button.setActionCommand(EDIT);
    button.addActionListener(this);

    //Set up the dialog that the button brings up.
    colorChooser = new JColorChooser();
    dialog = JColorChooser.createDialog(button, "Pick a Color", true, colorChooser, this, null);
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:22,代码来源:ColorCellEditor.java

示例14: textColor_actionPerformed

import javax.swing.JColorChooser; //导入依赖的package包/类
void textColor_actionPerformed(ActionEvent e) {
	int i=textColor.getSelectedIndex();
	if (i < colors.length){
		if(i!=stickerColor.getSelectedIndex()){
			stickerText.setForeground(colors[i]);
			textColor.setSelectedIndex(i);
		}
		else{
			textColor.setSelectedIndex(i+1);
			stickerText.setForeground(colors[i+1]);
			JOptionPane.showMessageDialog(this, Local.getString("SAME FOREGROUND COLOR"), "Error", 0);
		}
		stickerText.setForeground(colors[textColor.getSelectedIndex()]);
	}
	else {
		Color c =
			JColorChooser.showDialog(
				this,
				Local.getString("Text color"),
				stickerText.getForeground());
		if (c != null)
			stickerText.setForeground(c);
	}
	Context.put("TEXT_COLOR", new Integer(stickerText.getForeground().getRGB()));		
}
 
开发者ID:ser316asu,项目名称:Reinickendorf_SER316,代码行数:26,代码来源:StickerDialog.java

示例15: stickerColor_actionPerformed

import javax.swing.JColorChooser; //导入依赖的package包/类
void stickerColor_actionPerformed(ActionEvent e) {
	int i=stickerColor.getSelectedIndex();
	if (i< colors.length){
		if(i!=textColor.getSelectedIndex()){
			stickerText.setBackground(colors[i]);
			stickerColor.setSelectedIndex(i);
		}
		else{
			stickerColor.setSelectedIndex(i+1);
			stickerText.setBackground(colors[i+1]);
			JOptionPane.showMessageDialog(this, Local.getString("SAME BACKGROUND COLOR"), "Error", 0);
		}
		stickerText.setForeground(colors[textColor.getSelectedIndex()]);
	}
	else {
		Color c =
			JColorChooser.showDialog(
				this,
				Local.getString("Sticker color"),
				stickerText.getBackground());
		if (c != null)
			stickerText.setBackground(c);
	}
	Context.put("STICKER_COLOR", new Integer(stickerText.getBackground().getRGB()));
}
 
开发者ID:ser316asu,项目名称:Wilmersdorf_SER316,代码行数:26,代码来源:StickerDialog.java


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