javax.swing.JButton.setPressedIcon()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(212)

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

JButton.setPressedIcon介绍

暂无

代码示例

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

BufferedImage startButton = ImageIO.read(getClass().getResource("/icons/standard/buttons/start_backup.png"));
BufferedImage startButtonHover = ImageIO.read(getClass().getResource("/icons/standard/buttons/start_backup_hover.png"));
BufferedImage startButtonActive = ImageIO.read(getClass().getResource("/icons/standard/buttons/start_backup_active.png"));

JButton startBackupButton = new JButton(new ImageIcon(startButton));
startBackupButton.setRolloverIcon(new ImageIcon(startButtonHover));
startBackupButton.setPressedIcon(new ImageIcon(startButtonActive));
startBackupButton.setBorder(BorderFactory.createEmptyBorder());
startBackupButton.setContentAreaFilled(false);
startBackupButton.setFocusable(false);

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

JButton button = new JButton();
button.setBorderPainted(false);
button.setBorder(null);
//button.setFocusable(false);
button.setMargin(new Insets(0, 0, 0, 0));
button.setContentAreaFilled(false);
button.setIcon(myIcon1);
button.setRolloverIcon(myIcon2);
button.setPressedIcon(myIcon3);
button.setDisabledIcon(myIcon4);

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

@Override
public void setPressedIcon(Icon icon) {
  Icon arrow = updateIcons( icon, ICON_PRESSED );
  super.setPressedIcon( hasPopupMenu() ? arrow : icon );
}

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

/**
 * Creates a small 'close' JButton with close icon, rollover icon and pressed icon according to Look and Feel
 *
 * @return JButton with close icons.
 */
public static JButton createCloseButton() {
  JButton closeButton = new JButton();
  int size = 16;
  closeButton.setPreferredSize(new Dimension(size, size));
  closeButton.setContentAreaFilled(false);
  closeButton.setFocusable(false);
  closeButton.setBorder(BorderFactory.createEmptyBorder());
  closeButton.setBorderPainted(false);
  closeButton.setRolloverEnabled(true);
  closeButton.setIcon(ImageUtilities.image2Icon(getCloseTabImage()));
  closeButton.setRolloverIcon(ImageUtilities.image2Icon(getCloseTabRolloverImage()));
  closeButton.setPressedIcon(ImageUtilities.image2Icon(getCloseTabPressedImage()));
  return closeButton;
}

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

/**
 * Creates a big 'close' JButton with close icon, rollover icon and pressed icon according to Look and Feel
 *
 * @return JButton with close icons.
 */
public static JButton createBigCloseButton() {
  JButton closeButton = new JButton();
  int size = 19;
  closeButton.setPreferredSize(new Dimension(size, size));
  closeButton.setContentAreaFilled(false);
  closeButton.setFocusable(false);
  closeButton.setBorder(BorderFactory.createEmptyBorder());
  closeButton.setBorderPainted(false);
  closeButton.setRolloverEnabled(true);
  closeButton.setIcon(ImageUtilities.image2Icon(getBigCloseTabImage()));
  closeButton.setRolloverIcon(ImageUtilities.image2Icon(getBigCloseTabRolloverImage()));
  closeButton.setPressedIcon(ImageUtilities.image2Icon(getBigCloseTabPressedImage()));
  return closeButton;
}

代码示例来源:origin: jsettlers/settlers-remake

private void updateReadyButtonStyle() {
  if (isReady()) {
    readyButton.setIcon(READY_IMAGE);
    readyButton.setPressedIcon(READY_PRESSED_IMAGE);
    readyButton.setDisabledIcon(READY_DISABLED_IMAGE);
  } else {
    readyButton.setIcon(NOT_READY_IMAGE);
    readyButton.setPressedIcon(NOT_READY_PRESSED_IMAGE);
    readyButton.setDisabledIcon(NOT_READY_DISABLED_IMAGE);
  }
}

代码示例来源:origin: org.bidib.jbidib.com.vldocking/vldocking

/** installs the icons and tooltip suitable for a maximize button */
protected void configureMaximizeButton(JButton btn) {
  btn.setIcon(maximizeIcon);
  btn.setRolloverIcon(maximizeIconRollover);
  btn.setPressedIcon(maximizeIconPressed);
  btn.setRolloverSelectedIcon(maximizeIconRollover);
  btn.setToolTipText(MAXIMIZE_TEXT);
}

代码示例来源:origin: org.bidib.jbidib.com.vldocking/vldocking

/** installs the icons and tooltip suitable for a hide button */
protected void configureHideButton(JButton btn) {
  btn.setIcon(hideIcon);
  btn.setRolloverIcon(hideIconRollover);
  btn.setPressedIcon(hideIconPressed);
  btn.setRolloverSelectedIcon(hideIconRollover);
  btn.setToolTipText(ICONIFY_TEXT);
}

代码示例来源:origin: org.bidib.jbidib.com.vldocking/vldocking

/** installs the icons and tooltip suitable for a restore button.
 */
protected void configureRestoreButton(JButton btn) {
  btn.setIcon(restoreIcon);
  btn.setRolloverIcon(restoreIconRollover);
  btn.setPressedIcon(restoreIconPressed);
  btn.setRolloverSelectedIcon(restoreIconRollover);
  btn.setToolTipText(RESTORE_TEXT);
}

代码示例来源:origin: org.bidib.jbidib.com.vldocking/vldocking

/** installs the icons and tooltip suitable for a float button */
protected void configureFloatButton(JButton btn) {
  btn.setIcon(floatIcon);
  btn.setRolloverIcon(floatIconRollover);
  btn.setPressedIcon(floatIconPressed);
  btn.setRolloverSelectedIcon(floatIconRollover);
  btn.setToolTipText(FLOAT_TEXT);
}

代码示例来源:origin: org.bidib.jbidib.com.vldocking/vldocking

/** installs the icons and tooltip suitable for a close button */
protected void configureCloseButton(JButton btn) {
  btn.setIcon(closeIcon);
  btn.setRolloverIcon(closeIconRollover);
  btn.setPressedIcon(closeIconPressed);
  btn.setRolloverSelectedIcon(closeIconRollover);
  btn.setToolTipText(CLOSE_TEXT);
}

代码示例来源:origin: org.bidib.jbidib.com.vldocking/vldocking

/** installs the icons and tooltip suitable for a dock button */
protected void configureDockButton(JButton btn) {
  btn.setIcon(dockIcon);
  btn.setRolloverIcon(dockIconRollover);
  btn.setPressedIcon(dockIconPressed);
  btn.setRolloverSelectedIcon(dockIconRollover);
  btn.setToolTipText(RESTORE_TEXT);
}

代码示例来源:origin: org.bidib.jbidib.com.vldocking/vldocking

/** installs the icons and tooltip suitable for an attach button */
protected void configureAttachButton(JButton btn) {
  btn.setIcon(attachIcon);
  btn.setRolloverIcon(attachIconRollover);
  btn.setPressedIcon(attachIconPressed);
  btn.setRolloverSelectedIcon(attachIconRollover);
  btn.setToolTipText(ATTACH_TEXT);
}

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

JButton button = new JButton();
button.setBorderPainted(false);
button.setBorder(null);
button.setMargin(new Insets(0, 0, 0, 0));
button.setContentAreaFilled(false);
button.setIcon(myIcon1);
button.setRolloverIcon(myIcon2);
button.setPressedIcon(myIcon3);
button.setDisabledIcon(myIcon4);

代码示例来源:origin: org.gephi/ui-components

@Override
public void setPressedIcon(Icon icon) {
  Icon arrow = updateIcons(icon, ICON_PRESSED);
  super.setPressedIcon(hasPopupMenu() ? arrow : icon);
}

代码示例来源:origin: net.sf.squirrel-sql.plugins/graph

public HideDockButtonHandler(JToggleButton btnToClickOnHide, GraphPluginResources rsrc)
{
 _btnToClickOnHide = btnToClickOnHide;
 _bntHide = new JButton(rsrc.getIcon(GraphPluginResources.IKeys.HIDE_DOCK));
 _bntHide.setPressedIcon(rsrc.getIcon(GraphPluginResources.IKeys.HIDE_DOCK_SEL));
 _bntHide.setToolTipText(s_stringMgr.getString("graph.GraphQuerySQLPanel.hide"));
 _bntHide.setBorder(BorderFactory.createEmptyBorder());
 _bntHide.addActionListener(new ActionListener()
 {
   @Override
   public void actionPerformed(ActionEvent e)
   {
    _btnToClickOnHide.doClick(0);
   }
 });
}

代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client

public static JButton getIconButton(ImageIcon icon, int cornerRadius) {
  BufferedImage original = convertImageToType(icon.getImage(), BufferedImage.TYPE_4BYTE_ABGR);
  BufferedImage unselectedImage = original;
  BufferedImage selectedImage = darkenImage(original);
  if (cornerRadius > 0) {
    unselectedImage = makeRoundedCorner(unselectedImage, cornerRadius);
    selectedImage = makeRoundedCorner(selectedImage, cornerRadius);
  }
  final JButton button = new JButton(new ImageIcon(unselectedImage));
  button.setPressedIcon(new ImageIcon(selectedImage));
  button.setFocusable(false);
  button.setContentAreaFilled(false);
  button.setBorder(null);
  //ViewUtil.makeSmall(button);
  return button;
}

代码示例来源:origin: AlexFalappa/nb-springboot

public void setLinkReference(String url, String title) {
  Objects.requireNonNull(url);
  if (bReference == null) {
    bReference = new JButton();
    bReference.setIcon(ICO_QST_LGHT);
    bReference.setRolloverIcon(ICO_QST_MDM);
    bReference.setPressedIcon(ICO_QST_DRK);
    bReference.setMargin(INSETS_SMALLBUTTON);
    bReference.setOpaque(false);
    bReference.setContentAreaFilled(false);
    bReference.setBorderPainted(false);
    bReference.setFocusable(false);
    bReference.putClientProperty("Nimbus.Overrides", uiDef);
    bReference.addActionListener(refActionListener);
    this.add(bReference);
  }
  bReference.setToolTipText(title != null && !title.isEmpty() ? String.format("Reference: %s", title) : "Reference");
  bReference.putClientProperty(PROP_REFERENCE_TEMPLATE_URL, url);
}

代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler

/**
 * Creates welcome screen-specific button
 */
private JButton createButton(Icon outIcon, Icon overIcon) {
  JButton button = new JButton();
  button.setFocusPainted(false);
  button.setFocusable(false);
  button.setBorderPainted(false);
  button.setOpaque(false);
  button.setContentAreaFilled(false);
  button.setPressedIcon(overIcon);
  button.setRolloverIcon(overIcon);
  button.setIcon(outIcon);
  button.setSize(outIcon.getIconWidth(), outIcon.getIconHeight());
  return button;
}

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

JComponent     title = ((BasicInternalFrameUI)myInternalFrame.getUI()).getNorthPane();
 for (int i = 0; i < title.getComponentCount(); i++) {
   JComponent component = (JComponent)title.getComponent(i);
   if(component instanceof JButton) {
     JButton button = ((JButton)component);
     if(button.getName() == null) continue;
     if(button.getName().endsWith("closeButton")) {
       button.setIcon(myIcon);
       button.setSelectedIcon(myIcon);
       button.setPressedIcon(myIcon);
     }
     if(button.getName().endsWith("maximizeButton")) {
       ...
     }
     if(button.getName().endsWith("iconifyButton")) {
       ...
     }
   }
 }

相关文章

JButton类方法