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


Java AbstractButton.setDisplayedMnemonicIndex方法代码示例

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


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

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

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

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

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