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


Java AbstractButton.addPropertyChangeListener方法代码示例

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


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

示例1: setMnemonicIndex

import javax.swing.AbstractButton; //导入方法依赖的package包/类
/**
 * Wrapper for the
 * <code>AbstractButton.setMnemonicIndex</code> or
 * <code>JLabel.setDisplayedMnemonicIndex</code> method.
 * @param item AbstractButton/JLabel or subclasses
 * @param index Index of the Character to underline under JDK1.4
 * @param latinCode Latin Character Keycode to underline under JDK1.3
 */
private static void setMnemonicIndex(Object item, int index) {
    if (item instanceof AbstractButton) {
        AbstractButton b = (AbstractButton) item;
        b.putClientProperty(PROP_DISPLAYED_MNEMONIC_INDEX, index);
        b.removePropertyChangeListener(PROP_DISPLAYED_MNEMONIC_INDEX, MNEMONIC_INDEX_LISTENER);
        b.setDisplayedMnemonicIndex(index);
        b.addPropertyChangeListener(PROP_DISPLAYED_MNEMONIC_INDEX, MNEMONIC_INDEX_LISTENER);
    } else if (item instanceof JLabel) {
        ((JLabel) item).setDisplayedMnemonicIndex(index);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:Mnemonics.java

示例2: 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


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