javax.swing.AbstractButton.setDisabledIcon()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(146)

本文整理了Java中javax.swing.AbstractButton.setDisabledIcon()方法的一些代码示例,展示了AbstractButton.setDisabledIcon()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractButton.setDisabledIcon()方法的具体详情如下:
包路径:javax.swing.AbstractButton
类名称:AbstractButton
方法名:setDisabledIcon

AbstractButton.setDisabledIcon介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

JButton button = new JButton(imageIcon);
JButton button2 = new JButton(imageIcon);
button.setDisabledIcon(imageIcon);
button.setEnabled(false);
button2.setEnabled(false);

代码示例来源:origin: org.netbeans.api/org-openide-awt

if( i != null ) {
  button.setIcon((Icon) i);
  button.setDisabledIcon(ImageUtilities.createDisabledIcon((Icon) i));
  if (i instanceof Icon) {
    button.setIcon((Icon) i);
    button.setDisabledIcon(ImageUtilities.createDisabledIcon((Icon) i));
  } else {
  if (imgIcon != null) {
    button.setIcon(imgIcon);
    button.setDisabledIcon(ImageUtilities.createDisabledIcon(imgIcon));
  button.setDisabledIcon(dImgIcon);
} else if (imgIcon != null) {
  button.setDisabledIcon(ImageUtilities.createDisabledIcon(imgIcon));

代码示例来源:origin: org.netbeans.api/org-openide-awt

i = imgIcon;
  button.setIcon(imgIcon);
  button.setDisabledIcon(ImageUtilities.createDisabledIcon(imgIcon));
} else {
  SystemAction sa = (SystemAction) action;
  i = sa.getIcon(useTextIcons());
  button.setIcon((Icon) i);
  button.setDisabledIcon(ImageUtilities.createDisabledIcon((Icon) i));
i = sa.getIcon(useTextIcons());
button.setIcon((Icon) i);
button.setDisabledIcon(ImageUtilities.createDisabledIcon((Icon) i));
  i = imgIcon;
  button.setIcon((Icon) i);
  button.setDisabledIcon(ImageUtilities.createDisabledIcon(imgIcon));
} else {
  i = action.getValue(Action.SMALL_ICON);
  if (i instanceof Icon) {
    button.setIcon((Icon) i);
    button.setDisabledIcon(ImageUtilities.createDisabledIcon((Icon) i));
  } else {
    button.setIcon(nonNullIcon(null));
if (i instanceof Icon) {
  button.setIcon((Icon) i);
  button.setDisabledIcon(ImageUtilities.createDisabledIcon((Icon) i));
} else {
  button.setIcon(nonNullIcon(null));

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/napkinlaf

@Override
protected void overrideValue(JComponent c, Icon newValue) {
  if (!(newValue == null || newValue instanceof NapkinIcon)) {
    ((AbstractButton) c).setDisabledIcon(new SketchifiedIcon(c,
        newValue));
  }
}

代码示例来源:origin: stackoverflow.com

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Button extends JFrame {

  private JButton button;
  private JPanel p;

  public Button() {
    super("The title");
    p = new JPanel(new BorderLayout());
    button = new JButton();

    ImageIcon icon = new ImageIcon(getClass().getResource("button2.jpg"));
    button.setIcon(icon);
    button.setDisabledIcon(icon);

    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(400, 400);
    p.add(button);
    add(p);

  }
}

代码示例来源:origin: stackoverflow.com

btn.setDisabledIcon(new ImageIcon(getClass().getResource("/test.png")));
btn.addActionListener(new someListener());

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

public static JPopupButton createStrokeWidthButton(
    DrawingEditor editor, double[] widths, ResourceBundleUtil labels) {
  JPopupButton strokeWidthPopupButton = new JPopupButton();
  labels.configureToolBarButton(strokeWidthPopupButton, "attribute.strokeWidth");
  strokeWidthPopupButton.setFocusable(false);
  NumberFormat formatter = NumberFormat.getInstance();
  if (formatter instanceof DecimalFormat) {
    ((DecimalFormat) formatter).setMaximumFractionDigits(1);
    ((DecimalFormat) formatter).setMinimumFractionDigits(0);
  }
  for (int i = 0; i < widths.length; i++) {
    String label = Double.toString(widths[i]);
    Icon icon = new StrokeIcon(new BasicStroke((float) widths[i], BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    AttributeAction a = new AttributeAction(
        editor,
        STROKE_WIDTH,
        new Double(widths[i]),
        label,
        icon);
    a.putValue(ActionUtil.UNDO_PRESENTATION_NAME_KEY, labels.getString("attribute.strokeWidth.text"));
    AbstractButton btn = strokeWidthPopupButton.add(a);
    btn.setDisabledIcon(icon);
  }
  return strokeWidthPopupButton;
}

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

icon));
dsp.add(a);
btn.setDisabledIcon(icon);

代码示例来源:origin: net.sf.tinylaf/tinylaf

CopyPastePanel(CP cp) {
  super(new GridLayout(2, 1, 0, 2));
  
  this.cp = cp;
  
  if(copyIcon == null) {
    copyIcon = TinyLookAndFeel.loadIcon("cp_icons/mencopy.gif");
    pasteIcon = TinyLookAndFeel.loadIcon("cp_icons/menpaste.gif");
    pasteDisabledIcon = TinyLookAndFeel.loadIcon("cp_icons/menpastedis.gif");
  }
  
  JButton b = new IconButton(copyIcon);
  b.setActionCommand("copy");
  b.setToolTipText("Copy Parameter Set");
  b.addActionListener(this);
  add(b);
  
  pasteButton = new IconButton(pasteIcon);
  pasteButton.setDisabledIcon(pasteDisabledIcon);
  pasteButton.setActionCommand("paste");
  pasteButton.setToolTipText("Paste Parameter Set");
  pasteButton.addActionListener(this);
  pasteButton.setEnabled(false);
  add(pasteButton);
}

代码示例来源:origin: stackoverflow.com

toggleButton.setRolloverIcon((infoIcon));
toggleButton.setPressedIcon(warnIcon);
toggleButton.setDisabledIcon(warnIcon);
add(toggleButton);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

代码示例来源:origin: com.github.arnabk/pgslookandfeel

Image img = ((ImageIcon) ico).getImage();
if (b.getDisabledIcon() == null) {
  b.setDisabledIcon(PgsUtils.getDisabledButtonIcon(img));

代码示例来源:origin: com.github.arnabk/pgslookandfeel

Image img = ((ImageIcon) ico).getImage();
if (b.getDisabledIcon() == null) {
  b.setDisabledIcon(PgsUtils.getDisabledButtonIcon(img));

代码示例来源:origin: it.tidalwave.netbeans/it-tidalwave-netbeans-swing

public static JComponent[] fix (JComponent[] components, int size)
 {
  for (int i = 0; i < components.length; i++)
   {
    if (components[i] instanceof AbstractButton)
     {
      AbstractButton button = (AbstractButton)components[i];
      
      if (button.getIcon() != null)
       {
        button.setIcon(scaledIcon(button.getIcon(), size));
       }
      
      if (button.getDisabledIcon() != null)
       {
        button.setDisabledIcon(scaledIcon(button.getDisabledIcon(), size));
       }
     }
   }
  
  return components;
 }

代码示例来源:origin: com.jidesoft/jide-oss

/**
 * Creates the find next button. Subclass can override it to create your own find next button.
 *
 * @param findNextAction the find next action
 *
 * @return the find next button.
 */
protected AbstractButton createFindNextButton(AbstractAction findNextAction) {
  AbstractButton button = new JButton(_compact ? "" : getResourceString("SearchableBar.findNext"),
      getImageIcon(SearchableBarIconsFactory.Buttons.NEXT));
  button.setToolTipText(getResourceString("SearchableBar.findNext.tooltip"));
  button.setMnemonic(getResourceString("SearchableBar.findNext.mnemonic").charAt(0));
  button.setRolloverIcon(getImageIcon(SearchableBarIconsFactory.Buttons.NEXT_ROLLOVER));
  button.setDisabledIcon(getImageIcon(SearchableBarIconsFactory.Buttons.NEXT_DISABLED));
  button.setRequestFocusEnabled(false);
  button.setFocusable(false);
  button.addActionListener(findNextAction);
  button.setEnabled(false);
  return button;
}

代码示例来源:origin: com.jidesoft/jide-oss

/**
 * Creates the find prev button. Subclass can override it to create your own find prev button.
 *
 * @param findPrevAction the find previous action
 *
 * @return the find prev button.
 */
protected AbstractButton createFindPrevButton(AbstractAction findPrevAction) {
  AbstractButton button = new JButton(_compact ? "" : getResourceString("SearchableBar.findPrevious"),
      getImageIcon(SearchableBarIconsFactory.Buttons.PREVIOUS));
  button.setToolTipText(getResourceString("SearchableBar.findPrevious.tooltip"));
  button.setMnemonic(getResourceString("SearchableBar.findPrevious.mnemonic").charAt(0));
  button.setRolloverIcon(getImageIcon(SearchableBarIconsFactory.Buttons.PREVIOUS_ROLLOVER));
  button.setDisabledIcon(getImageIcon(SearchableBarIconsFactory.Buttons.PREVIOUS_DISABLED));
  button.setRequestFocusEnabled(false);
  button.setFocusable(false);
  button.addActionListener(findPrevAction);
  button.setEnabled(false);
  return button;
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-bu

_button.setPressedIcon(null);
_button.setRolloverIcon(null);
_button.setDisabledIcon(null);
_button.setSelectedIcon(null);
_button.setRolloverSelectedIcon(null);

代码示例来源:origin: com.jidesoft/jide-oss

/**
 * Creates the highlight button.
 *
 * @return the highlight button.
 */
protected AbstractButton createHighlightButton() {
  AbstractButton button = new JToggleButton(_compact ? "" : getResourceString("SearchableBar.highlights"),
      getImageIcon(SearchableBarIconsFactory.Buttons.HIGHLIGHTS));
  button.setToolTipText(getResourceString("SearchableBar.highlights.tooltip"));
  button.setMnemonic(getResourceString("SearchableBar.highlights.mnemonic").charAt(0));
  button.setSelectedIcon(getImageIcon(SearchableBarIconsFactory.Buttons.HIGHLIGHTS_SELECTED));
  button.setDisabledIcon(getImageIcon(SearchableBarIconsFactory.Buttons.HIGHLIGHTS_DISABLED));
  button.setRolloverIcon(getImageIcon(SearchableBarIconsFactory.Buttons.HIGHLIGHTS_ROLLOVER));
  button.setRolloverSelectedIcon(getImageIcon(SearchableBarIconsFactory.Buttons.HIGHLIGHTS_ROLLOVER_SELECTED));
  button.setRequestFocusEnabled(false);
  button.setFocusable(false);
  AbstractAction highlightAllAction = new AbstractAction() {
    private static final long serialVersionUID = 5170786863522331175L;
    public void actionPerformed(ActionEvent e) {
      addSearchingTextToHistory(getSearchingText());
      highlightAllOrNext();
    }
  };
  button.addActionListener(highlightAllAction);
  button.setEnabled(false);
  return button;
}

代码示例来源:origin: org.softsmithy.lib/lib-core

Icon icon = action.getSmallDisabledIcon();
if (icon != null) {
  button.setDisabledIcon(icon);

代码示例来源:origin: org.softsmithy.lib/softsmithy-lib-swing

Icon icon = action.getSmallDisabledIcon();
if (icon != null) {
  button.setDisabledIcon(icon);

代码示例来源:origin: org.softsmithy.lib/softsmithy-lib-swing

Icon icon = action.getLargeDisabledIcon();
if (icon != null) {
  button.setDisabledIcon(icon);

相关文章

微信公众号

最新文章

更多

AbstractButton类方法