当前位置: 首页>>代码示例>>Java>>正文


Java AbstractButton.setIcon方法代码示例

本文整理汇总了Java中javax.swing.AbstractButton.setIcon方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractButton.setIcon方法的具体用法?Java AbstractButton.setIcon怎么用?Java AbstractButton.setIcon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.AbstractButton的用法示例。


在下文中一共展示了AbstractButton.setIcon方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureToolbarButton

import javax.swing.AbstractButton; //导入方法依赖的package包/类
private void configureToolbarButton (AbstractButton item, String containerCtx, String action, ActionProvider provider, Map ctx) {
        item.setFocusable(false);
        item.setName(action);
        item.putClientProperty (KEY_ACTION, action);
        item.setToolTipText(
            provider.getDisplayName(action, containerCtx));
//        item.setToolTipText(provider.getDescription(action, containerCtx));
        int state = ctx == null ? ActionProvider.STATE_VISIBLE :
            provider.getState (action, containerCtx, ctx);
        boolean enabled = (state & ActionProvider.STATE_ENABLED) != 0;
        item.setEnabled(enabled);
        boolean visible = (state & ActionProvider.STATE_VISIBLE) != 0;
        item.setVisible (visible);
        boolean toggled = (state & ActionProvider.STATE_SELECTED) != 0;
        item.setSelected(toggled);
//        item.setMnemonic(provider.getMnemonic(action, containerCtx));
//        item.setDisplayedMnemonicIndex(provider.getMnemonicIndex(action, containerCtx));
        item.setIcon(provider.getIcon(action, containerCtx, BeanInfo.ICON_COLOR_16x16));
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:AbstractToolbarFactory.java

示例2: updateButton

import javax.swing.AbstractButton; //导入方法依赖的package包/类
/** Updates the state of those pushbuttons in the left
 * vertical tool box that need to indicate the special "ambiguous"
 * state marking that some of the currently selected components
 * have the respective property set while some do not.
 */
private void updateButton(AbstractButton button, boolean nonEmptySelection, boolean allSelectedUnambiguous, String iconWarning, String toolTipWarning, String iconNormal, String toolTipNormal) {
    button.setSelected(allSelectedUnambiguous);
    if(nonEmptySelection && !allSelectedUnambiguous) {
        button.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/form/layoutsupport/griddesigner/resources/" + iconWarning, false)); // NOI18N
        button.setToolTipText(NbBundle.getMessage(GridBagCustomizer.class, "GridBagCustomizer." + toolTipWarning)); // NOI18N
    } else {
        button.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/form/layoutsupport/griddesigner/resources/" + iconNormal, false)); // NOI18N
        button.setToolTipText(NbBundle.getMessage(GridBagCustomizer.class, "GridBagCustomizer." + toolTipNormal)); // NOI18N
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:GridBagCustomizer.java

示例3: updateButtonIcons

import javax.swing.AbstractButton; //导入方法依赖的package包/类
static void updateButtonIcons(AbstractButton button, Icon icon, boolean useLargeIcon, String iconResource) {
    button.setIcon(icon);

    if (iconResource != null) {
        String base = iconResource;
        String suffix = "";
        int dotIndex;
        if ((dotIndex = iconResource.lastIndexOf('.')) >= 0) {
            suffix = iconResource.substring(dotIndex, iconResource.length());
            base = iconResource.substring(0, dotIndex);
        }
        if (useLargeIcon) {
            base += LARGE_ICON_SIZE_STRING;
        }

        Icon pressedIcon = ImageUtilities.loadImageIcon(base + "_pressed" + suffix, true); // NOI18N
        if (pressedIcon != null) {
            button.setPressedIcon(pressedIcon);
        }
        Icon rolloverIcon = ImageUtilities.loadImageIcon(base + "_rollover" + suffix, true); // NOI18N
        if (rolloverIcon != null) {
            button.setRolloverIcon(rolloverIcon);
        }
        Icon disabledIcon = ImageUtilities.loadImageIcon(base + "_disabled" + suffix, true); // NOI18N
        if (disabledIcon != null) {
            button.setDisabledIcon(disabledIcon);
        } else { // Make disabled icon from regular icon
            button.setDisabledIcon(ImageUtilities.createDisabledIcon(icon));
        }
        Icon selectedIcon = ImageUtilities.loadImageIcon(base + "_selected" + suffix, true); // NOI18N
        if (selectedIcon != null) {
            button.setSelectedIcon(selectedIcon);
        }
        Icon rolloverSelectedIcon = ImageUtilities.loadImageIcon(base + "_rolloverSelected" + suffix, true); // NOI18N
        if (rolloverSelectedIcon != null) {
            button.setRolloverSelectedIcon(rolloverSelectedIcon);
        }
        Icon disabledSelectedIcon = ImageUtilities.loadImageIcon(base + "_disabledSelected" + suffix, true); // NOI18N
        if (disabledSelectedIcon != null) {
            button.setDisabledSelectedIcon(disabledSelectedIcon);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:44,代码来源:EditorActionUtilities.java

示例4: initialize

import javax.swing.AbstractButton; //导入方法依赖的package包/类
/**
 * Initializes a specified presenter.
 *
 * @param  presenter  presenter to initialize
 */
private void initialize(AbstractButton presenter, boolean useIcons) {

    if (useIcons) {
        // set the presenter's icon:
        Image icon = ImageUtilities.loadImage(
                "org/netbeans/modules/url/urlObject.png");              //NOI18N
        try {
            FileObject file = dataObject.getPrimaryFile();
            icon = FileUIUtils.getImageDecorator(file.getFileSystem()).
                    annotateIcon(icon,
                        BeanInfo.ICON_COLOR_16x16,
                        dataObject.files());
        } catch (FileStateInvalidException fsie) {
            // OK, so we use the default icon
        }
        presenter.setIcon(new ImageIcon(icon));
    }

    /* set the presenter's text and ensure it is maintained up-to-date: */
    NameChangeListener listener = new NameChangeListener(presenter);
    presenter.addPropertyChangeListener(
            WeakListeners.propertyChange(listener, dataObject));
    updateName(presenter);
    /*
     * The above code works with the assumption that it is called
     * from the AWT event dispatching thread (it manipulates
     * the presenter's display name). The same applies to
     * NameChangeListener's method propertyChange(...).
     *
     * At least, both mentioned parts of code should be called from
     * the same thread since method updateText(...) is not thread-safe.
     */

    presenter.addActionListener(this);
    HelpCtx.setHelpIDString(presenter,
                            dataObject.getHelpCtx().getHelpID());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:43,代码来源:URLPresenter.java

示例5: setIcons

import javax.swing.AbstractButton; //导入方法依赖的package包/类
final public static void setIcons(AbstractButton objPabstractButton, Icon objPicon, Icon objProllOverIcon, Icon objPdisabledIcon) {
	final Icon objLicon = objPicon != null ? objPicon : objProllOverIcon;
	final Icon objLrollOverIcon = objProllOverIcon != null ? objProllOverIcon : objPicon;
	objPabstractButton.setIcon(objLicon);
	objPabstractButton.setSelectedIcon(objLicon);
	objPabstractButton.setPressedIcon(objLrollOverIcon);
	objPabstractButton.setRolloverIcon(objLrollOverIcon);
	objPabstractButton.setRolloverSelectedIcon(objLrollOverIcon);
	if (objPdisabledIcon != null) {
		objPabstractButton.setDisabledIcon(objPdisabledIcon);
		objPabstractButton.setDisabledSelectedIcon(objPdisabledIcon);
	}
}
 
开发者ID:jugglemaster,项目名称:JuggleMasterPro,代码行数:14,代码来源:Tools.java


注:本文中的javax.swing.AbstractButton.setIcon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。