javax.swing.colorchooser.AbstractColorChooserPanel Java Examples

The following examples show how to use javax.swing.colorchooser.AbstractColorChooserPanel. 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: Test4177735.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
Example #2
Source File: Test4177735.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
Example #3
Source File: Test4177735.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
Example #4
Source File: ViewUtils.java    From GIFKR with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void fixOsxColorChooser(JColorChooser chooser) {

		if(!UIManager.getLookAndFeel().getName().equals("Mac OS X"))
			return;

		AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
		for(JPanel p : panels) {
			if(p!=null) {
				p.setOpaque(false);
				((JComponent) p.getParent()).setOpaque(false);
				for(Component c : p.getComponents()) {
					((JComponent) c).setBorder(null);
					((JComponent) c).setOpaque(false);
				}
			}
		}
	}
 
Example #5
Source File: Test4177735.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
Example #6
Source File: Test4177735.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
Example #7
Source File: Test4177735.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
Example #8
Source File: Test4177735.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
Example #9
Source File: Test4177735.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
Example #10
Source File: Test4177735.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
Example #11
Source File: Test4177735.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
Example #12
Source File: Test4177735.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
Example #13
Source File: Test4177735.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
Example #14
Source File: JColorChooserOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code JColorChooser.getChooserPanels()} through queue
 */
public AbstractColorChooserPanel[] getChooserPanels() {
    return ((AbstractColorChooserPanel[]) runMapping(new MapAction<Object>("getChooserPanels") {
        @Override
        public Object map() {
            return ((JColorChooser) getSource()).getChooserPanels();
        }
    }));
}
 
Example #15
Source File: JColorChooserOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
        }
    });
}
 
Example #16
Source File: GraphColorChooser.java    From constellation with Apache License 2.0 5 votes vote down vote up
public GraphColorChooser() {
    // Add our named color panel by getting the existing panels and putting ours in front.
    final AbstractColorChooserPanel[] panels = ColorChooserComponentFactory.getDefaultChooserPanels();
    final AbstractColorChooserPanel[] morePanels = new AbstractColorChooserPanel[panels.length + 1];
    morePanels[0] = new NamedColorPanel();
    System.arraycopy(panels, 0, morePanels, 1, panels.length);

    setChooserPanels(morePanels);
}
 
Example #17
Source File: JColorChooserOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps
 * {@code JColorChooser.removeChooserPanel(AbstractColorChooserPanel)}
 * through queue
 */
public AbstractColorChooserPanel removeChooserPanel(final AbstractColorChooserPanel abstractColorChooserPanel) {
    return (runMapping(new MapAction<AbstractColorChooserPanel>("removeChooserPanel") {
        @Override
        public AbstractColorChooserPanel map() {
            return ((JColorChooser) getSource()).removeChooserPanel(abstractColorChooserPanel);
        }
    }));
}
 
Example #18
Source File: AdrComponentsFactory.java    From MercuryTrade with MIT License 5 votes vote down vote up
private JColorChooser getColorChooser() {
    JColorChooser colorChooser = new JColorChooser();
    String type = UIManager.getString("ColorChooser.hsvNameText", colorChooser.getLocale());
    for (AbstractColorChooserPanel p : colorChooser.getChooserPanels()) {
        if (!p.getDisplayName().equals(type)) {
            colorChooser.removeChooserPanel(p);
        }
    }
    return colorChooser;
}
 
Example #19
Source File: CColorChooser.java    From binnavi with Apache License 2.0 5 votes vote down vote up
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 #20
Source File: ColorButton.java    From PyramidShader with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 #21
Source File: ColorChooserPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
protected Color showMoreColorsDialog() {
    JColorChooser colorChooser = new JColorChooser(getSelectedColor());
    AbstractColorChooserPanel[] oldChooserPanels = colorChooser.getChooserPanels();
    AbstractColorChooserPanel[] newChooserPanels = new AbstractColorChooserPanel[oldChooserPanels.length + 1];
    System.arraycopy(oldChooserPanels, 0, newChooserPanels, 1, oldChooserPanels.length);
    newChooserPanels[0] = new MyAbstractColorChooserPanel();
    colorChooser.setChooserPanels(newChooserPanels);
    ColorTracker colorTracker = new ColorTracker(colorChooser);
    JDialog dialog = JColorChooser.createDialog(this, "Select Colour", true, colorChooser, colorTracker, null);
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    dialog.setVisible(true);
    return colorTracker.getColor();
}
 
Example #22
Source File: ExtendedColorChooser.java    From nextreports-designer with Apache License 2.0 5 votes vote down vote up
private static void addChooserPanels(JColorChooser chooser) {
	AbstractColorChooserPanel[] oldPanels = chooser.getChooserPanels();
    AbstractColorChooserPanel[] newPanels = new AbstractColorChooserPanel[oldPanels.length+2];        
    newPanels[0] =  new ExcelColorChooserPanel();
    newPanels[newPanels.length-1] = historyPanel; 
    System.arraycopy(oldPanels, 0, newPanels, 1, oldPanels.length);
    chooser.setChooserPanels(newPanels);
}
 
Example #23
Source File: DarkColorChooserUI.java    From darklaf with MIT License 5 votes vote down vote up
@Override
protected AbstractColorChooserPanel[] createDefaultChoosers() {
    return new AbstractColorChooserPanel[]{
                                           new DarkColorChooserPanel(DarkColorModelRGB.getInstance(),
                                                                     DarkColorModelHSB.getInstance(),
                                                                     DarkColorModelHSL.getInstance(),
                                                                     DarkColorModelCMYK.getInstance()),
                                           new DarkSwatchesChooserPanel(),
    };
}
 
Example #24
Source File: Test4177735.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    int hsvIndex = 0;
    int panelsLength;
    int finalIndex;
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    panelsLength = panels.length;

    for(int i = 0; i < panelsLength; i++) {
        if(panels[i].getDisplayName().equals("HSV")) {
            hsvIndex = i;
        }
    }
    finalIndex = Math.min(hsvIndex, panelsLength - 1);
    chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[finalIndex] });

    JDialog dialog = show(chooser);
    pause(DELAY);

    dialog.dispose();
    pause(DELAY);

    Test4177735 test = new Test4177735();
    SwingUtilities.invokeAndWait(test);
    if (test.count != 0) {
        throw new Error("JColorChooser leaves " + test.count + " threads running");
    }
}
 
Example #25
Source File: ViewUtils.java    From GIFKR with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static AbstractColorChooserPanel findPanel(JColorChooser chooser, String name) {
	AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
	for (int i = 0; i < panels.length; i++) {
		String clsName = panels[i].getClass().getName();
		if (clsName.equals(name)) {
			return panels[i];
		}
	}
	return null;
}
 
Example #26
Source File: ColorSlidersChooser.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void installChooserPanel(JColorChooser enclosingChooser) {
    super.installChooserPanel(enclosingChooser);
    Component[] components = slidersHolder.getComponents();
    for (int i=0; i < components.length; i++) {
        AbstractColorChooserPanel ccp = (AbstractColorChooserPanel) components[i];
        ccp.installChooserPanel(enclosingChooser);
    }
}
 
Example #27
Source File: ColorSlidersChooser.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Invoked when the panel is removed from the chooser.
 * If override this, be sure to call <code>super</code>.
 */
public void uninstallChooserPanel(JColorChooser enclosingChooser) {
    Component[] components = slidersHolder.getComponents();
    for (int i=0; i < components.length; i++) {
        AbstractColorChooserPanel ccp = (AbstractColorChooserPanel) components[i];
        ccp.uninstallChooserPanel(enclosingChooser);
    }
    super.uninstallChooserPanel(enclosingChooser);
}
 
Example #28
Source File: JColorChooserOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps
 * {@code JColorChooser.addChooserPanel(AbstractColorChooserPanel)}
 * through queue
 */
public void addChooserPanel(final AbstractColorChooserPanel abstractColorChooserPanel) {
    runMapping(new MapVoidAction("addChooserPanel") {
        @Override
        public void map() {
            ((JColorChooser) getSource()).addChooserPanel(abstractColorChooserPanel);
        }
    });
}
 
Example #29
Source File: Quaqua13ColorChooserUI.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent e) {
    
    if (e.getPropertyName().equals( JColorChooser.CHOOSER_PANELS_PROPERTY)) {
        AbstractColorChooserPanel[] oldPanels = (AbstractColorChooserPanel[]) e.getOldValue();
        AbstractColorChooserPanel[] newPanels = (AbstractColorChooserPanel[]) e.getNewValue();
        
        for (int i = 0; i < oldPanels.length; i++) {  // remove old panels
            Container wrapper = oldPanels[i].getParent();
            if (wrapper != null) {
                Container parent = wrapper.getParent();
                if (parent != null)
                    parent.remove(wrapper);  // remove from hierarchy
                oldPanels[i].uninstallChooserPanel(chooser); // uninstall
            }
        }
        
        mainPanel.removeAllColorChooserPanels();
        for (int i = 0; i < newPanels.length; i++) {
            if (newPanels[i] != null) {
            mainPanel.addColorChooserPanel((SubstanceColorChooserPanel) newPanels[i]);
            }
        }
        
        for (int i = 0; i < newPanels.length; i++) {
            if (newPanels[i] != null) {
            newPanels[i].installChooserPanel(chooser);
            }
        }
    }
    
    if ( e.getPropertyName().equals( JColorChooser.PREVIEW_PANEL_PROPERTY)) {
        if (e.getNewValue() != previewPanel) {
            installPreviewPanel();
        }
    }
}
 
Example #30
Source File: Test4711996.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) {
    JColorChooser chooser = new JColorChooser();
    AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
    chooser.removeChooserPanel(panels[0]);
    chooser.updateUI();
}