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); } }
/** 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); } }); }
/** 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; }
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); } }); }
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 } }
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(); } }); }
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(); } } }
/** * 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()); }
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); }
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); }
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); } } }
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 }
/** * 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); }
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())); }
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())); }
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"); } } }
private void jPanelSkyColourMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanelSkyColourMouseClicked Color initialBackground = new Color(0, 0, 0); Color background = JColorChooser.showDialog(null, "Set Colour", initialBackground); if ((background != null) && (background != jPanelSkyColour.getBackground())) { stopStarEffect(); gKeyboard.getEffect().SkyColour = IOOperations.getHexStringFromColour(background); gKeyboard.setAllKeys(gKeyboard.getEffect().SkyColour, true); jPanelSkyColour.setBackground(background); jPanelColour115.setBackground(jPanelStarColour.getBackground()); jLayeredPane1.moveToBack(jPanelColour115); jPanelColour116.setBackground(jPanelStarColour.getBackground()); jLayeredPane1.moveToBack(jPanelColour116); gKeyboard.setGroupKeys("logo", gKeyboard.getEffect().StarColour, true); startStarEffect(gKeyboard.getEffect().StarColour, IOOperations.getHexStringFromColour(background)); } }
private void jPanelFixedColourMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanelFixedColourMouseClicked Color initialBackground = new Color(255, 0, 0); Color background = JColorChooser.showDialog(null, "Set Colour", initialBackground); String[] colours = new String[keyCount]; String hexColour = "ff0000"; if (background != null) { jPanelFixedColour.setBackground(background); gKeyboard.getEffect().FixedColour = IOOperations.getHexStringFromColour(background); for (int i = 0; i < colours.length; i++) { colours[i] = IOOperations.getHexStringFromColour(background); } } else { for (int i = 0; i < colours.length; i++) { colours[i] = hexColour; } } loadColoursToVirtualKeyboard(colours); gKeyboard.setFXColor(gKeyboard.getEffect().FixedColour); }
protected void changeColor() { int selectedIndex = list.getSelectedIndex(); FlagListItem item = (FlagListItem)listModel.elementAt(selectedIndex); Color c = JColorChooser.showDialog(this, "Choose color", item.getColor()); if (c != null) { item.setColor(c); colorButton.setColor(c); } }
void colorB_actionPerformed(ActionEvent e) { // Fix until Sun's JVM supports more locales... UIManager.put( "ColorChooser.swatchesNameText", Local.getString("Swatches")); UIManager.put("ColorChooser.hsbNameText", Local.getString("HSB")); UIManager.put("ColorChooser.rgbNameText", Local.getString("RGB")); UIManager.put( "ColorChooser.swatchesRecentText", Local.getString("Recent:")); UIManager.put("ColorChooser.previewText", Local.getString("Preview")); UIManager.put( "ColorChooser.sampleText", Local.getString("Sample Text") + " " + Local.getString("Sample Text")); UIManager.put("ColorChooser.okText", Local.getString("OK")); UIManager.put("ColorChooser.cancelText", Local.getString("Cancel")); UIManager.put("ColorChooser.resetText", Local.getString("Reset")); UIManager.put("ColorChooser.hsbHueText", Local.getString("H")); UIManager.put("ColorChooser.hsbSaturationText", Local.getString("S")); UIManager.put("ColorChooser.hsbBrightnessText", Local.getString("B")); UIManager.put("ColorChooser.hsbRedText", Local.getString("R")); UIManager.put("ColorChooser.hsbGreenText", Local.getString("G")); UIManager.put("ColorChooser.hsbBlueText", Local.getString("B2")); UIManager.put("ColorChooser.rgbRedText", Local.getString("Red")); UIManager.put("ColorChooser.rgbGreenText", Local.getString("Green")); UIManager.put("ColorChooser.rgbBlueText", Local.getString("Blue")); Color c = JColorChooser.showDialog(this, Local.getString("Font color"), Util.decodeColor(colorField.getText())); if (c == null) return; colorField.setText(Util.encodeColor(c)); Util.setColorField(colorField); sample.setForeground(c); }
/** * Maps {@code JColorChooser.setColor(int)} through queue */ public void setColor(final int i) { runMapping(new MapVoidAction("setColor") { @Override public void map() { ((JColorChooser) getSource()).setColor(i); } }); }
/** * Maps * {@code JColorChooser.setChooserPanels(AbstractColorChooserPanel[])} * through queue */ public void setChooserPanels(final AbstractColorChooserPanel[] abstractColorChooserPanel) { runMapping(new MapVoidAction("setChooserPanels") { @Override public void map() { ((JColorChooser) getSource()).setChooserPanels(abstractColorChooserPanel); } }); }
private void initGui() { setLayout(new BorderLayout()); add(Buttons.create().text(Messages.get().message("color")).focusable(false).onClick((ev) -> { Color ret = JColorChooser.showDialog(null, "Choose a color", color); setValue(ret); valueListener.valueChanged(ret, ret); })); }
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{ // When the last color in the array is applied to text color and sticker color, // decrement down the array so we don't cause ArrayOutOfBounds //System.out.println(i); if(i != 12) { textColor.setSelectedIndex(i+1); stickerText.setForeground(colors[i+1]); } else { textColor.setSelectedIndex(i); stickerText.setForeground(colors[i-4]); // change to a lighter color } 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())); }
@Override public void init() { JButton button = new JButton("Swap models"); button.addActionListener(this); this.chooser = new JColorChooser(Color.RED); this.chooser.setSelectionModel(WHITE); add(BorderLayout.NORTH, button); add(BorderLayout.CENTER, this.chooser); }
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"); } }
/** * Shows a dialog where the user can select the plot background color. */ private void createLineColorDialog() { Color oldColor = line.getFormat().getColor(); if (oldColor == null) { oldColor = Color.BLACK; } Color newLineColor = JColorChooser.showDialog(null, I18N.getGUILabel("edit_parallel_line.line_color_title.label"), oldColor); if (newLineColor != null && !(newLineColor.equals(oldColor))) { lineColor = newLineColor; } }
/** * */ public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof mxGraphComponent) { mxGraphComponent graphComponent = (mxGraphComponent) e.getSource(); Color newColor = JColorChooser.showDialog(graphComponent, mxResources.get("pageBackground"), null); if (newColor != null) { graphComponent.setPageBackgroundColor(newColor); } // Forces a repaint of the component graphComponent.repaint(); } }
private void createLegendFrameColorDialog() { Color oldColor = getPlotConfiguration().getLegendConfiguration().getLegendFrameColor(); if (oldColor == null) { oldColor = LegendConfiguration.DEFAULT_LEGEND_FRAME_COLOR; } Color newBackgroundColor = JColorChooser.showDialog(this, I18N.getGUILabel("plotter.configuration_dialog.global_config_panel.legend_frame_color_title.label"), oldColor); if (newBackgroundColor != null && !(newBackgroundColor.equals(oldColor))) { getPlotConfiguration().getLegendConfiguration().setLegendFrameColor(newBackgroundColor); } }
/** * Allows the user the opportunity to change the outline paint. */ private void attemptModifyLabelPaint() { Color c; c = JColorChooser.showDialog( this, localizationResources.getString("Label_Color"), Color.blue ); if (c != null) { this.labelPaintSample.setPaint(c); } }
private void createDomainAxisColorDialog() { Color oldColor = getPlotConfiguration().getAxisLineColor(); if (oldColor == null) { oldColor = Color.black; } Color newLineColor = JColorChooser.showDialog(this, I18N.getGUILabel("plotter.configuration_dialog.global_config_panel.plot_background_color_title.label"), oldColor); if (newLineColor != null && !(newLineColor.equals(oldColor))) { getPlotConfiguration().setAxisLineColor(newLineColor); } }
private void createItemColorDialog() { if (getSelectedValueSource() != null) { Color itemColor = getSelectedValueSource().getSeriesFormat().getItemColor(); Color newItemColor = JColorChooser.showDialog(this, I18N.getGUILabel("plotter.configuration_dialog.choose_color.label"), itemColor); if (newItemColor != null && !(newItemColor.equals(itemColor))) { getSelectedValueSource().getSeriesFormat().setItemColor(newItemColor); } } }
/** * Allow the user to change the outline paint. We use JColorChooser, so * the user can only choose colors (a subset of all possible paints). */ private void attemptOutlinePaintSelection() { Color c; c = JColorChooser.showDialog( this, localizationResources.getString("Outline_Color"), Color.blue ); if (c != null) { this.outlinePaintSample.setPaint(c); } }
/** * Constructor. * * @param comp a component */ public JColorChooserOperator(JColorChooser comp) { super(comp); setTimeouts(JemmyProperties.getProperties().getTimeouts()); setOutput(JemmyProperties.getProperties().getOutput()); tabbed = new JTabbedPaneOperator(this); }
@BeforeMethod public void showDialog() throws Throwable { JavaElementFactory.add(JColorChooser.class, JColorChooserJavaElement.class); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { frame = new JFrame("My Dialog"); frame.setName("dialog-1"); JColorChooser colorChooser = new JColorChooser(); frame.getContentPane().add(colorChooser); frame.pack(); frame.setAlwaysOnTop(true); frame.setVisible(true); } }); driver = new JavaAgent(); }