當前位置: 首頁>>代碼示例>>Java>>正文


Java AbstractButton.setMnemonic方法代碼示例

本文整理匯總了Java中javax.swing.AbstractButton.setMnemonic方法的典型用法代碼示例。如果您正苦於以下問題:Java AbstractButton.setMnemonic方法的具體用法?Java AbstractButton.setMnemonic怎麽用?Java AbstractButton.setMnemonic使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.AbstractButton的用法示例。


在下文中一共展示了AbstractButton.setMnemonic方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setMnemonic

import javax.swing.AbstractButton; //導入方法依賴的package包/類
/**
 * Wrapper for AbstractButton.setMnemonic and JLabel.setDisplayedMnemonic
 * @param item AbstractButton/JLabel
 * @param mnem Mnemonic char to set, latin [a-z,A-Z], digit [0-9], or any VK_ code
 */
private static void setMnemonic(Object item, int mnem) {
    if (isAquaLF()) {
        // there shall be no mnemonics on macosx.
        //#55864
        return;
    }

    if ((mnem >= 'a') && (mnem <= 'z')) {
        mnem = mnem + ('A' - 'a');
    }

    if (item instanceof AbstractButton) {
        AbstractButton b = (AbstractButton) item;
        b.putClientProperty(PROP_MNEMONIC, mnem);
        b.setMnemonic(mnem);
    } else {
        ((JLabel) item).setDisplayedMnemonic(mnem);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:Mnemonics.java

示例2: addMnemonicsToButtons

import javax.swing.AbstractButton; //導入方法依賴的package包/類
/**
 * dodanie mneomonikow do przyciskow
 *
 * @param parentComponent - komponent
 * @param text - nazwy przyciskow
 * @param mnemonic - mnemoniki dla przyciskow
 */
private static void addMnemonicsToButtons(Component parentComponent, String[] text, int[] mnemonic) {
    Collection<Component> components = getAllSubComponents(parentComponent);
    for (Component child : components) {
        if (child instanceof AbstractButton) {
            AbstractButton b = (AbstractButton) child;
            String btnText = b.getText();
            if (btnText == null) {
                btnText = "";
            }
            int textCount = text.length;
            for (int j = 0; j < textCount; j++) {
                if (btnText.equals(text[j])) {
                    b.setMnemonic(mnemonic[j]);
                }
            }
        }
    }
}
 
開發者ID:CLARIN-PL,項目名稱:WordnetLoom,代碼行數:26,代碼來源:DialogBox.java

示例3: setLocalizedText

import javax.swing.AbstractButton; //導入方法依賴的package包/類
/**
 * Actual setter of the text & mnemonics for the AbstractButton or
 * their subclasses. We must copy necessary code from org.openide.awt.Mnemonics
 * because org.openide.awt module is not available yet when this code is called.
 * @param item AbstractButton
 * @param text new label
 */
private static void setLocalizedText (AbstractButton button, String text) {
    if (text == null) {
        button.setText(null);
        return;
    }

    int i = findMnemonicAmpersand(text);

    if (i < 0) {
        // no '&' - don't set the mnemonic
        button.setText(text);
        button.setMnemonic(0);
    } else {
        button.setText(text.substring(0, i) + text.substring(i + 1));
        
        if (Utilities.isMac()) {
            // there shall be no mnemonics on macosx.
            //#55864
            return;
        }

        char ch = text.charAt(i + 1);

        // it's latin character or arabic digit,
        // setting it as mnemonics
        button.setMnemonic(ch);

        // If it's something like "Save &As", we need to set another
        // mnemonic index (at least under 1.4 or later)
        // see #29676
        button.setDisplayedMnemonicIndex(i);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:41,代碼來源:AcceptLicense.java

示例4: propertyChange

import javax.swing.AbstractButton; //導入方法依賴的package包/類
public void propertyChange(PropertyChangeEvent evt) {
    AbstractButton b = (AbstractButton) evt.getSource();
    if (b.getDisplayedMnemonicIndex() == -1) {
        Integer mnemonic = (Integer) b.getClientProperty(PROP_MNEMONIC);
        Integer index = (Integer) b.getClientProperty(PROP_DISPLAYED_MNEMONIC_INDEX);
        if (mnemonic != null && index != null && Utilities.compareObjects(b.getText(), b.getClientProperty(PROP_TEXT))) {
            b.setMnemonic(mnemonic);
            b.setDisplayedMnemonicIndex(index);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:Mnemonics.java

示例5: configureAbstractButton

import javax.swing.AbstractButton; //導入方法依賴的package包/類
private void configureAbstractButton(AbstractButton button, String resource) {
    String title = resources.getString(resource);
    int i = title.indexOf('&');
    int mnemonic = 0;
    if (i >= 0) {
        mnemonic = title.charAt(i + 1);
        title = title.substring(0, i) + title.substring(i + 1);
        button.setText(title);
        button.setMnemonic(Character.toUpperCase(mnemonic));
        button.setDisplayedMnemonicIndex(i);
    } else
        button.setText(title);
}
 
開發者ID:CBSkarmory,項目名稱:AWGW,代碼行數:14,代碼來源:WorldFrame.java


注:本文中的javax.swing.AbstractButton.setMnemonic方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。