Java Code Examples for javax.swing.colorchooser.AbstractColorChooserPanel

The following examples show how to use javax.swing.colorchooser.AbstractColorChooserPanel. These examples are extracted from open source projects. 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 Project: dragonwell8_jdk   Source File: Test4177735.java    License: 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 Project: TencentKona-8   Source File: Test4177735.java    License: 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 Project: jdk8u60   Source File: Test4177735.java    License: 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 Project: openjdk-jdk8u   Source File: Test4177735.java    License: 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 5
Source Project: GIFKR   Source File: ViewUtils.java    License: 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 6
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 Project: jdk8u-jdk   Source File: Test4177735.java    License: 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 Project: hottub   Source File: Test4177735.java    License: 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 Project: openjdk-8-source   Source File: Test4177735.java    License: 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 Project: openjdk-8   Source File: Test4177735.java    License: 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 Project: jdk8u_jdk   Source File: Test4177735.java    License: 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 Project: jdk8u-jdk   Source File: Test4177735.java    License: 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 Project: jdk8u-dev-jdk   Source File: Test4177735.java    License: 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 Project: constellation   Source File: GraphColorChooser.java    License: 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 15
Source Project: darklaf   Source File: DarkColorChooserUI.java    License: 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 16
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 17
/**
 * 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 18
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 19
Source Project: GIFKR   Source File: ViewUtils.java    License: 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 20
Source Project: openjdk-jdk9   Source File: Test4177735.java    License: 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 21
/**
 * 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 22
/**
 * 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 23
/**
 * 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 24
/**
 * 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 25
Source Project: MercuryTrade   Source File: AdrComponentsFactory.java    License: 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 26
Source Project: binnavi   Source File: CColorChooser.java    License: 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 27
Source Project: PyramidShader   Source File: ColorButton.java    License: 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 28
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 29
Source Project: nextreports-designer   Source File: ExtendedColorChooser.java    License: 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 30
Source Project: dragonwell8_jdk   Source File: Test4711996.java    License: 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();
}