Java Swing Menu setMenuText(AbstractButton item, String text, boolean useMnemonic)

Here you can find the source of setMenuText(AbstractButton item, String text, boolean useMnemonic)

Description

DOCUMENT ME!

License

Open Source License

Parameter

Parameter Description
item DOCUMENT ME!
text DOCUMENT ME!
useMnemonic DOCUMENT ME!

Declaration

public static void setMenuText(AbstractButton item, String text, boolean useMnemonic) 

Method Source Code

//package com.java2s;
/*/*from w w  w  . ja v a2  s. c o m*/
 * Copyright (c) 2001-2002, Marco Hunsicker. All rights reserved.
 *
 * This software is distributable under the BSD license. See the terms of the
 * BSD license in the documentation provided with this software.
 */

import javax.swing.AbstractButton;

public class Main {
    /**
     * DOCUMENT ME!
     *
     * @param item DOCUMENT ME!
     * @param text DOCUMENT ME!
     * @param useMnemonic DOCUMENT ME!
     */
    public static void setMenuText(AbstractButton item, String text, boolean useMnemonic) {
        int i = text.indexOf('&');

        if (i < 0) {
            item.setText(text);
        } else {
            item.setText(text.substring(0, i) + text.substring(i + 1));

            if (useMnemonic) {
                item.setMnemonic(text.charAt(i + 1));
            }
        }
    }
}

Related

  1. menuDigit(int digit)
  2. menuKeystroke(int virtualKey)
  3. removeMenuMnemonics(MenuElement[] elements)
  4. setFontsToMenu(MenuElement menuElement, Font font)
  5. setMenuFont(Object item, Font theFont)
  6. setMenuUp(boolean s, JComponent c)
  7. setViewportMenu(JComponent c)
  8. showContextMenu()
  9. showRCMenu(JTextComponent text, MouseEvent e)