本文整理汇总了Java中javax.swing.colorchooser.AbstractColorChooserPanel类的典型用法代码示例。如果您正苦于以下问题:Java AbstractColorChooserPanel类的具体用法?Java AbstractColorChooserPanel怎么用?Java AbstractColorChooserPanel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractColorChooserPanel类属于javax.swing.colorchooser包,在下文中一共展示了AbstractColorChooserPanel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fixOsxColorChooser
import javax.swing.colorchooser.AbstractColorChooserPanel; //导入依赖的package包/类
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);
}
}
}
}
示例2: showDialog
import javax.swing.colorchooser.AbstractColorChooserPanel; //导入依赖的package包/类
public static Color showDialog(Component component, String title,
Color initial) {
JColorChooser choose = new JColorChooser(initial);
JDialog dialog = createDialog(component, title, true, choose, null, null);
AbstractColorChooserPanel[] panels = choose.getChooserPanels();
for (AbstractColorChooserPanel accp : panels) {
choose.removeChooserPanel(accp);
}
GrayScaleSwatchChooserPanel grayScaleSwatchChooserPanelFreeStyle = new GrayScaleSwatchChooserPanel();
GrayScalePanel grayScalePanelFreeStyle = new GrayScalePanel();
choose.addChooserPanel(grayScaleSwatchChooserPanelFreeStyle);
choose.addChooserPanel(grayScalePanelFreeStyle);
dialog.getContentPane().add(choose);
dialog.pack();
dialog.setVisible(true);//.show();
return choose.getColor();
}
示例3: main
import javax.swing.colorchooser.AbstractColorChooserPanel; //导入依赖的package包/类
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");
}
}
示例4: setChooserPanels
import javax.swing.colorchooser.AbstractColorChooserPanel; //导入依赖的package包/类
/**
* This method sets the chooserPanels property for this JColorChooser.
*
* @param panels The new set of AbstractColorChooserPanels to use.
*/
public void setChooserPanels(AbstractColorChooserPanel[] panels)
{
if (panels != chooserPanels)
{
if (chooserPanels != null)
for (int i = 0; i < chooserPanels.length; i++)
if (chooserPanels[i] != null)
chooserPanels[i].uninstallChooserPanel(this);
AbstractColorChooserPanel[] old = chooserPanels;
chooserPanels = panels;
if (panels != null)
for (int i = 0; i < panels.length; i++)
if (panels[i] != null)
panels[i].installChooserPanel(this);
firePropertyChange(CHOOSER_PANELS_PROPERTY, old, chooserPanels);
}
}
示例5: addColorChooser
import javax.swing.colorchooser.AbstractColorChooserPanel; //导入依赖的package包/类
private void addColorChooser() {
// remove unwanted, extra color chooser features like other color
// options and preview
AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
AbstractColorChooserPanel[] newPanels = { panels[0] };
chooser.setChooserPanels(newPanels);
// customize preview panel
JLabel preview = new JLabel("\u25FC\u25FC\u25FC\u25FC\u25FC", JLabel.CENTER);
preview.setFont(new Font("Serif", Font.BOLD, 18));
chooser.setPreviewPanel(preview);
chooser.getSelectionModel().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
canvas.updateColor(chooser.getColor());
}
});
southPanel.add(chooser, BorderLayout.WEST);
}
示例6: setColorChooserDialog
import javax.swing.colorchooser.AbstractColorChooserPanel; //导入依赖的package包/类
private void setColorChooserDialog() {
jColorChooser.setPreviewPanel(new JPanel());
AbstractColorChooserPanel[] panels = jColorChooser.getChooserPanels();
for (AbstractColorChooserPanel p : panels) {
String displayName = p.getDisplayName();
switch (displayName.toUpperCase()) {
case "HSV":
jColorChooser.removeChooserPanel(p);
break;
case "HSL":
jColorChooser.removeChooserPanel(p);
break;
case "CMYK":
jColorChooser.removeChooserPanel(p);
break;
case "SWATCHES":
jColorChooser.removeChooserPanel(p);
break;
}
}
}
示例7: createSwatchColorChooser
import javax.swing.colorchooser.AbstractColorChooserPanel; //导入依赖的package包/类
private JColorChooser createSwatchColorChooser() {
final JColorChooser chooser = new JColorChooser();
AbstractColorChooserPanel swatchPanel = chooser.getChooserPanels()[0];
for (AbstractColorChooserPanel panel : chooser.getChooserPanels()) {
if (panel != swatchPanel) { // Swatch panel
chooser.removeChooserPanel(panel);
}
}
chooser.setPreviewPanel(new JPanel());
chooser.getSelectionModel().addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
setPaint(chooser.getColor());
hueColorChooser.setColor(chooser.getColor());
rgbColorChooser.setColor(chooser.getColor());
}
});
return chooser;
}
示例8: createHueColorChooser
import javax.swing.colorchooser.AbstractColorChooserPanel; //导入依赖的package包/类
private JColorChooser createHueColorChooser() {
final JColorChooser chooser = new JColorChooser();
AbstractColorChooserPanel hsvPanel = chooser.getChooserPanels()[1];
for (AbstractColorChooserPanel panel : chooser.getChooserPanels()) {
if (panel != hsvPanel) { // Hue panel
chooser.removeChooserPanel(panel);
}
}
chooser.setPreviewPanel(new JPanel());
chooser.getSelectionModel().addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
setPaint(chooser.getColor());
swatchColorChooser.setColor(chooser.getColor());
rgbColorChooser.setColor(chooser.getColor());
}
});
return chooser;
}
示例9: createRGBColorChooser
import javax.swing.colorchooser.AbstractColorChooserPanel; //导入依赖的package包/类
private JColorChooser createRGBColorChooser() {
final JColorChooser chooser = new JColorChooser();
AbstractColorChooserPanel rgbPanel;
if (chooser.getChooserPanels().length > 3) {
rgbPanel = chooser.getChooserPanels()[3];
} else {
rgbPanel = chooser.getChooserPanels()[2];
}
for (AbstractColorChooserPanel panel : chooser.getChooserPanels()) {
if (panel != rgbPanel) { // RGB panel
chooser.removeChooserPanel(panel);
}
}
chooser.setPreviewPanel(new JPanel());
chooser.getSelectionModel().addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
setPaint(chooser.getColor());
swatchColorChooser.setColor(chooser.getColor());
hueColorChooser.setColor(chooser.getColor());
}
});
return chooser;
}
示例10: removeChooserPanel
import javax.swing.colorchooser.AbstractColorChooserPanel; //导入依赖的package包/类
public AbstractColorChooserPanel removeChooserPanel(AbstractColorChooserPanel panel) {
AbstractColorChooserPanel panelToRemove = null;
int index = 0;
for (int i = 0; i < chooserPanels.length; i++) {
if (panel.equals(chooserPanels[i])) {
panelToRemove = chooserPanels[i];
index = i;
break;
}
}
if (panelToRemove == null) {
throw new IllegalArgumentException(Messages.getString("swing.0A")); //$NON-NLS-1$
}
AbstractColorChooserPanel[] newChooserPanels = new AbstractColorChooserPanel[chooserPanels.length - 1];
System.arraycopy(chooserPanels, 0, newChooserPanels, 0, index);
System.arraycopy(chooserPanels, index + 1, newChooserPanels, index,
newChooserPanels.length - index);
setChooserPanels(newChooserPanels);
return panelToRemove;
}
示例11: testUninstallDefaultChoosers
import javax.swing.colorchooser.AbstractColorChooserPanel; //导入依赖的package包/类
public void testUninstallDefaultChoosers() throws Exception {
assertEquals(2, ch.getComponentCount());
assertNotNull(findComponent(ch, JTabbedPane.class, true));
assertEquals(3, ((JTabbedPane) findComponent(ch, JTabbedPane.class, true))
.getTabCount());
ch.removeChooserPanel(ch.getChooserPanels()[0]);
assertEquals(2, ch.getComponentCount());
assertNotNull(findComponent(ch, JTabbedPane.class, true));
assertEquals(2, ((JTabbedPane) findComponent(ch, JTabbedPane.class, true))
.getTabCount());
ch.removeChooserPanel(ch.getChooserPanels()[0]);
assertEquals(2, ch.getComponentCount());
assertNull(findComponent(ch, JTabbedPane.class, true));
ch.removeChooserPanel(ch.getChooserPanels()[0]);
assertEquals(2, ch.getComponentCount());
assertNull(findComponent(ch, JTabbedPane.class, true));
ui.defaultChoosers = new AbstractColorChooserPanel[0];
ui.uninstallDefaultChoosers();
assertEquals(2, ch.getComponentCount());
assertNull(findComponent(ch, JTabbedPane.class, true));
}
示例12: ColorButton
import javax.swing.colorchooser.AbstractColorChooserPanel; //导入依赖的package包/类
/**
* 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();
}
示例13: findPanel
import javax.swing.colorchooser.AbstractColorChooserPanel; //导入依赖的package包/类
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;
}
示例14: PreferencesJColorChooser
import javax.swing.colorchooser.AbstractColorChooserPanel; //导入依赖的package包/类
/**
* Constructs
*
* @param objPcontrolJFrame
* @param objPpreferencesJDialog
* @param bytPcolorPreferenceType
*/
public PreferencesJColorChooser(ControlJFrame objPcontrolJFrame, PreferencesJDialog objPpreferencesJDialog, byte bytPcolorPreferenceType) {
// Init panels :
this.objGcontrolJFrame = objPcontrolJFrame;
this.objGpreferencesJDialog = objPpreferencesJDialog;
this.bytGcolorPreferenceType = bytPcolorPreferenceType;
this.setOpaque(true);
this.setColor(Tools.getPenColor(this.objGpreferencesJDialog.strGstringLocalAA[this.bytGcolorPreferenceType][Constants.bytS_UNCLASS_TEMPORARY_CURRENT]));
this.setPreviewPanel(new JPanel());
final AbstractColorChooserPanel[] objLabstractColorChooserPanelA = this.getChooserPanels();
for (final AbstractColorChooserPanel objLabstractColorChooserPanel : objLabstractColorChooserPanelA) {
if (!objLabstractColorChooserPanel.getClass().getName().equals("javax.swing.colorchooser.DefaultHSBChooserPanel")) {
this.removeChooserPanel(objLabstractColorChooserPanel);
}
}
// Actions.doSetFont(this, this.objGcontrolJFrame.getFont());
// Init listeners :
this.getSelectionModel().addChangeListener(this);
this.objGoKActionListener =
new PreferencesJColorChooserJDialogListener(this.objGpreferencesJDialog, this, this.bytGcolorPreferenceType, true);
this.objGcancelActionListener =
new PreferencesJColorChooserJDialogListener(this.objGpreferencesJDialog,
this,
this.bytGcolorPreferenceType,
false);
}
示例15: setPopUp
import javax.swing.colorchooser.AbstractColorChooserPanel; //导入依赖的package包/类
final public void setPopUp() {
if (this.objGjWindow != null) {
this.objGjWindow.dispose();
}
this.objGjWindow = new JWindow(this.objGcontrolJFrame.getJuggleMasterPro().getFrame());
switch (this.bytGlocalStringType) {
case Constants.bytS_STRING_LOCAL_JUGGLER_DAY:
case Constants.bytS_STRING_LOCAL_SITESWAP_DAY:
case Constants.bytS_STRING_LOCAL_BACKGROUND_DAY:
this.objGjColorChooser = new JColorChooser();
final AbstractColorChooserPanel[] objLabstractColorChooserPanelA = this.objGjColorChooser.getChooserPanels();
for (final AbstractColorChooserPanel objLabstractColorChooserPanel : objLabstractColorChooserPanelA) {
// if
// (objLabstractColorChooserPanel.getClass().getName().equals("javax.swing.colorchooser.DefaultHSBChooserPanel"))
// {
if (objLabstractColorChooserPanel.getClass().getName().equals("javax.swing.colorchooser.DefaultSwatchChooserPanel")) {
objLabstractColorChooserPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
this.objGjWindow.add(objLabstractColorChooserPanel);
break;
}
}
break;
case Constants.bytS_STRING_LOCAL_COLORS:
this.setBallsColorsPopUp();
//$FALL-THROUGH$
default:
this.objGjColorChooser = null;
break;
}
this.objGjWindow.pack();
this.objGjWindow.setLocation( (int) Constants.objS_GRAPHICS_TOOLKIT.getScreenSize().getWidth(),
(int) Constants.objS_GRAPHICS_TOOLKIT.getScreenSize().getHeight());
}