Java Swing Menu getMenuKeyStroke(String stroke)

Here you can find the source of getMenuKeyStroke(String stroke)

Description

get Menu Key Stroke

License

Open Source License

Declaration

public static KeyStroke getMenuKeyStroke(String stroke) 

Method Source Code


//package com.java2s;
/*//from   w ww .ja va 2  s.  co m
 * This file is part of the Jose Project
 * see http://jose-chess.sourceforge.net/
 * (c) 2002-2006 Peter Sch?fer
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 */

import javax.swing.*;

import java.awt.*;

public class Main {
    public static KeyStroke getMenuKeyStroke(String stroke) {
        KeyStroke key = KeyStroke.getKeyStroke(stroke);
        if (key != null && (key.getModifiers() & Event.CTRL_MASK) != 0) {
            //  replace CTRL key with local preferred key (e.g. Command on Mac)
            key = KeyStroke.getKeyStroke(key.getKeyCode(), (key.getModifiers() & ~(Event.CTRL_MASK + 0x80))
                    | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), key.isOnKeyRelease());
        }
        return key;
    }
}

Related

  1. findMenuBar(Container container)
  2. findMenuElement(final MenuElement root, final String text)
  3. fixIconTextGap(JComponent menu)
  4. getAllMenuSubElements( MenuElement root)
  5. getMenuFontHeight()
  6. getMenuSectionLabel(String string)
  7. getOperationMenu(MenuElement currentMenu, String path)
  8. getParsedElements(MenuElement[] elements)
  9. getTheMenuBar(String[][] arr)