javax.swing.colorchooser.ColorSelectionModel Java Examples
The following examples show how to use
javax.swing.colorchooser.ColorSelectionModel.
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: SequentialColorPalettePanel.java From colorbrewer with GNU Lesser General Public License v2.1 | 6 votes |
public void actionPerformed(ActionEvent e) { ColorSelectionModel model = getColorSelectionModel(); System.out.println("COLORSELECTIONMODEL: " + model); String command = ((JToggleButton)e.getSource()).getActionCommand(); for (ColorBrewer palette: ColorBrewer.getSequentialColorPalettes(isShowColorBlindSave())) { if (palette.name().equals(command)) { System.out.println(palette.name() + " comm:" + command); ((ColorPanelSelectionModel) model).setColorBrewer(palette); break; } } }
Example #2
Source File: PaletteUI.java From pumpernickel with MIT License | 5 votes |
@Override public void propertyChange(PropertyChangeEvent evt) { ColorSelectionModel oldModel = (ColorSelectionModel) evt .getOldValue(); ColorSelectionModel newModel = (ColorSelectionModel) evt .getNewValue(); if (oldModel != null) oldModel.removeChangeListener(colorSelectionListener); if (newModel != null) newModel.addChangeListener(colorSelectionListener); }
Example #3
Source File: StreetsJColorChooserPanel.java From VanetSim with GNU General Public License v3.0 | 5 votes |
/** * An implemented <code>ItemListener</code> to change colors when user changes value in the <code>comboBox</code>. * * @param itemEvent the received event * * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent) */ public void itemStateChanged(ItemEvent itemEvent) { int state = itemEvent.getStateChange(); if (state == ItemEvent.SELECTED) { int position = findColorLabel(itemEvent.getItem()); if (position != -1) { ColorSelectionModel selectionModel = getColorSelectionModel(); selectionModel.setSelectedColor(COLORS[position]); } } }
Example #4
Source File: AlphaColorChooserPanel.java From jclic with GNU General Public License v2.0 | 5 votes |
private void alphaSliderStateChanged(javax.swing.event.ChangeEvent evt) { // GEN-FIRST:event_alphaSliderStateChanged int v = alphaSlider.getValue(); alphaTxt.setText(Integer.toString(v)); ColorSelectionModel csm = getColorSelectionModel(); if (csm != null) { Color c = csm.getSelectedColor(); Color nc = v < 255 ? new Color(c.getRed(), c.getGreen(), c.getBlue(), v) : new Color(c.getRed(), c.getGreen(), c.getBlue()); csm.setSelectedColor(nc); } }
Example #5
Source File: QualitativeColorPalettePanel.java From colorbrewer with GNU Lesser General Public License v2.1 | 5 votes |
public void actionPerformed(ActionEvent e) { ColorSelectionModel model = getColorSelectionModel(); String command = ((JToggleButton)e.getSource()).getActionCommand(); for (ColorBrewer palette: ColorBrewer.getQualitativeColorPalettes(isShowColorBlindSave())) { if (palette.name().equals(command)) { ((ColorPanelSelectionModel) model).setColorBrewer(palette); break; } } }
Example #6
Source File: DivergingColorPalettePanel.java From colorbrewer with GNU Lesser General Public License v2.1 | 5 votes |
public void actionPerformed(ActionEvent e) { ColorSelectionModel model = getColorSelectionModel(); String command = ((JToggleButton)e.getSource()).getActionCommand(); for (ColorBrewer palette: ColorBrewer.getDivergingColorPalettes(isShowColorBlindSave())) { if (palette.name().equals(command)) { ((ColorPanelSelectionModel) model).setColorBrewer(palette); break; } } }
Example #7
Source File: ColorButton.java From PyramidShader with GNU General Public License v3.0 | 5 votes |
/** * Creates a new instance of ColorButton. Default color is black, default * size of the icon is 16 x 16 pixels. This button is registered with itself * for receiving action performed calls. */ public ColorButton() { this.color = new Color(0, 0, 0); this.iconHeight = 16; this.iconWidth = 16; this.colorChooserTitle = "Choose a Color"; //Set up the dialog that the button brings up. colorChooser = new JColorChooser(); // replace the ugly and useless preview panel by an empty JPanel colorChooser.setPreviewPanel(new JPanel()); // remove the swatch AbstractColorChooserPanel[] choosers = colorChooser.getChooserPanels(); for (AbstractColorChooserPanel chooser : choosers) { String clsName = chooser.getClass().getName(); if (clsName.equals("javax.swing.colorchooser.DefaultSwatchChooserPanel")) { colorChooser.removeChooserPanel(chooser); } } ColorSelectionModel colorSelectionModel = colorChooser.getSelectionModel(); colorSelectionModel.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent evt) { ColorSelectionModel model = (ColorSelectionModel) evt.getSource(); setColor(model.getSelectedColor()); } }); this.updateIcon(); }
Example #8
Source File: CColorChooser.java From binnavi with Apache License 2.0 | 5 votes |
public CColorChooser(final ColorSelectionModel model, final Color[] recentColors) { super(model); // Remove first chooser panel ("Swatches") // TODO(cblichmann): Revisit this for JDK > 1.7 final AbstractColorChooserPanel[] panels = getChooserPanels(); if (panels.length > 0) { removeChooserPanel(panels[0]); } m_recentColors = recentColors; if (m_recentColors != null) { addChooserPanel(new RecentColorsColorChooserPanel()); } }
Example #9
Source File: DarkSwatchesChooserPanel.java From darklaf with MIT License | 5 votes |
protected void setSelectedColor(final Color color) { ColorSelectionModel model = getColorSelectionModel(); previewPanel.setColor(color); if (model != null) { model.setSelectedColor(color); } }
Example #10
Source File: JColorChooserOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Maps {@code JColorChooser.setSelectionModel(ColorSelectionModel)} * through queue */ public void setSelectionModel(final ColorSelectionModel colorSelectionModel) { runMapping(new MapVoidAction("setSelectionModel") { @Override public void map() { ((JColorChooser) getSource()).setSelectionModel(colorSelectionModel); } }); }
Example #11
Source File: JColorChooserOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Maps {@code JColorChooser.getSelectionModel()} through queue */ public ColorSelectionModel getSelectionModel() { return (runMapping(new MapAction<ColorSelectionModel>("getSelectionModel") { @Override public ColorSelectionModel map() { return ((JColorChooser) getSource()).getSelectionModel(); } })); }
Example #12
Source File: Quaqua13ColorChooserUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void stateChanged( ChangeEvent e ) { ColorSelectionModel model = (ColorSelectionModel)e.getSource(); if (previewPanel != null) { previewPanel.setForeground(model.getSelectedColor()); previewPanel.repaint(); } }
Example #13
Source File: DarkColorChooserPanel.java From darklaf with MIT License | 5 votes |
@Override public void colorChanged(final Color color, final Object source) { if (isChanging || color == null) return; isChanging = true; currentColor = color; ColorSelectionModel model = getColorSelectionModel(); if (model != null) model.setSelectedColor(currentColor); applyColorToFields(color); if (source != textHex) textHex.setValue(color); previewComponent.setColor(color); colorWheelPanel.setColor(color, this); isChanging = false; }
Example #14
Source File: JPalette.java From pumpernickel with MIT License | 4 votes |
public ColorSelectionModel getColorSelectionModel() { return (ColorSelectionModel) getClientProperty( PROPERTY_SELECTION_MODEL); }
Example #15
Source File: JPalette.java From pumpernickel with MIT License | 4 votes |
public void setColorSelectionModel(ColorSelectionModel model) { Objects.requireNonNull(model); putClientProperty(PROPERTY_SELECTION_MODEL, model); }
Example #16
Source File: CColorChooser.java From binnavi with Apache License 2.0 | 4 votes |
public CColorChooser(final ColorSelectionModel model) { this(model, null); }
Example #17
Source File: JColorWell.java From pumpernickel with MIT License | 4 votes |
public ColorSelectionModel getColorSelectionModel() { return (ColorSelectionModel) getClientProperty(KEY_COLOR_SELECTION_MODEL); }
Example #18
Source File: JColorWell.java From pumpernickel with MIT License | 4 votes |
public void setColorSelectionModel(ColorSelectionModel colorSelectionModel) { Objects.requireNonNull(colorSelectionModel); putClientProperty(KEY_COLOR_SELECTION_MODEL, colorSelectionModel); }
Example #19
Source File: ColorPalettesChooser.java From radiance with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void setColorToModel(Color color) { ColorSelectionModel colorSelectionModel = getColorSelectionModel(); if (colorSelectionModel != null) { colorSelectionModel.setSelectedColor(color); } }
Example #20
Source File: WebColorChooser.java From weblaf with GNU General Public License v3.0 | 2 votes |
/** * Constructs new color chooser. * * @param model color selection model */ public WebColorChooser ( final ColorSelectionModel model ) { this ( StyleId.auto, model ); }
Example #21
Source File: WebColorChooser.java From weblaf with GNU General Public License v3.0 | 2 votes |
/** * Constructs new color chooser. * * @param id {@link StyleId} * @param model color selection model */ public WebColorChooser ( final StyleId id, final ColorSelectionModel model ) { super ( model ); setStyleId ( id ); }