當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。