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


Java MenuShortcut類代碼示例

本文整理匯總了Java中java.awt.MenuShortcut的典型用法代碼示例。如果您正苦於以下問題:Java MenuShortcut類的具體用法?Java MenuShortcut怎麽用?Java MenuShortcut使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: addMenuItems

import java.awt.MenuShortcut; //導入依賴的package包/類
void addMenuItems(Menu f, String[] m) {

        for (int i = 0; i < m.length; i++) {
            MenuItem item = new MenuItem(m[i].substring(1));
            char     c    = m[i].charAt(0);

            if (c != '-') {
                item.setShortcut(new MenuShortcut(c));
            }

            item.addActionListener(this);
            f.add(item);
        }
    }
 
開發者ID:Julien35,項目名稱:dev-courses,代碼行數:15,代碼來源:DatabaseManager.java

示例2: main

import java.awt.MenuShortcut; //導入依賴的package包/類
public static void main(String[] args) {
	
	Container container = new Container();
	Panel panel = new Panel();
	Menu menu = new Menu();	   			//!!! its not component
	TextField textField = new TextField();
	container.add(textField);
	
	Window win = new Window(null);
	win.pack();
	
	
	menu.setShortcut(new MenuShortcut(12));
	new MenuItem("label", new MenuShortcut(33, true));
	
	Menu file = new Menu("File"); 
	MenuItem print; 
	file.add(print = new MenuItem("Print", new MenuShortcut('p'))); 

}
 
開發者ID:wandrusz,項目名稱:wwwa,代碼行數:21,代碼來源:AWTExample.java

示例3: instantiate

import java.awt.MenuShortcut; //導入依賴的package包/類
@Override
protected Expression instantiate(Object oldInstance, Encoder enc) {
    MenuShortcut shortcut = (MenuShortcut) oldInstance;
    int keyCode = shortcut.getKey();
    boolean useShiftModifier = shortcut.usesShiftModifier();
    return new Expression(shortcut, shortcut.getClass(), BeansUtils.NEW,
            new Object[] { keyCode, useShiftModifier });
}
 
開發者ID:yippeesoft,項目名稱:NotifyTools,代碼行數:9,代碼來源:AwtMenuShortcutPersistenceDelegate.java

示例4: initFileMenu

import java.awt.MenuShortcut; //導入依賴的package包/類
private static Menu initFileMenu() {
  Menu mnFile = new Menu(Resources.get("menu_file"));

  MenuItem create = new MenuItem(Resources.get("menu_createProject"));
  create.setShortcut(new MenuShortcut(KeyEvent.VK_N));
  create.addActionListener(a -> EditorScreen.instance().create());

  MenuItem load = new MenuItem(Resources.get("menu_loadProject"));
  load.setShortcut(new MenuShortcut(KeyEvent.VK_O));
  load.addActionListener(a -> EditorScreen.instance().load());

  MenuItem save = new MenuItem(Resources.get("menu_save"));
  save.setShortcut(new MenuShortcut(KeyEvent.VK_S));
  save.addActionListener(a -> EditorScreen.instance().save(false));

  MenuItem saveAs = new MenuItem(Resources.get("menu_saveAs"));
  saveAs.addActionListener(a -> EditorScreen.instance().save(true));

  MenuItem exit = new MenuItem(Resources.get("menu_exit"));
  exit.setShortcut(new MenuShortcut(KeyEvent.VK_Q));
  exit.addActionListener(a -> Game.terminate());

  mnFile.add(load);
  mnFile.add(create);
  mnFile.add(save);
  mnFile.add(saveAs);
  mnFile.addSeparator();
  recentFiles = new Menu(Resources.get("menu_recentFiles"));
  loadRecentFiles();
  mnFile.add(recentFiles);
  mnFile.addSeparator();
  mnFile.add(exit);
  return mnFile;
}
 
開發者ID:gurkenlabs,項目名稱:litiengine,代碼行數:35,代碼來源:Program.java

示例5: setLabel

import java.awt.MenuShortcut; //導入依賴的package包/類
public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
    int keyMask = modifiers;
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut();

        if (shortcut != null) {
            keyCode = shortcut.getKey();
            keyMask |= InputEvent.META_MASK;

            if (shortcut.usesShiftModifier()) {
                keyMask |= InputEvent.SHIFT_MASK;
            }
        }
    }

    if (label == null) {
        label = "";
    }

    // <rdar://problem/3654824>
    // Native code uses a keyChar of 0 to indicate that the
    // keyCode should be used to generate the shortcut.  Translate
    // CHAR_UNDEFINED into 0.
    if (keyChar == KeyEvent.CHAR_UNDEFINED) {
        keyChar = 0;
    }

    nativeSetLabel(getModel(), label, keyChar, keyCode, keyMask);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:30,代碼來源:CMenuItem.java

示例6: addMenuItems

import java.awt.MenuShortcut; //導入依賴的package包/類
/**
 * Method declaration
 *
 *
 * @param f
 * @param m
 */
void addMenuItems(Menu f, String m[]) {

    for (int i = 0; i < m.length; i++) {
        MenuItem item = new MenuItem(m[i].substring(1));
        char     c    = m[i].charAt(0);

        if (c != '-') {
            item.setShortcut(new MenuShortcut(c));
        }

        item.addActionListener(this);
        f.add(item);
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:22,代碼來源:DatabaseManager.java

示例7: addMenuItems

import java.awt.MenuShortcut; //導入依賴的package包/類
/**
 * Method declaration
 *
 *
 * @param f
 * @param m
 */
void addMenuItems(Menu f, String[] m) {

    for (int i = 0; i < m.length; i++) {
        MenuItem item = new MenuItem(m[i].substring(1));
        char     c    = m[i].charAt(0);

        if (c != '-') {
            item.setShortcut(new MenuShortcut(c));
        }

        item.addActionListener(this);
        f.add(item);
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:22,代碼來源:DatabaseManager.java

示例8: setLabel

import java.awt.MenuShortcut; //導入依賴的package包/類
public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
    int keyMask = modifiers;
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut();

        if (shortcut != null) {
            keyCode = shortcut.getKey();
            keyMask |= InputEvent.META_MASK;

            if (shortcut.usesShiftModifier()) {
                keyMask |= InputEvent.SHIFT_MASK;
            }
        }
    }

    if (label == null) {
        label = "";
    }

    // <rdar://problem/3654824>
    // Native code uses a keyChar of 0 to indicate that the
    // keyCode should be used to generate the shortcut.  Translate
    // CHAR_UNDEFINED into 0.
    if (keyChar == KeyEvent.CHAR_UNDEFINED) {
        keyChar = 0;
    }

    final String finalLabel = label;
    final char finalKeyChar = keyChar;
    final int finalKeyCode = keyCode;
    final int finalKeyMask = keyMask;
    execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar,
                                  finalKeyCode, finalKeyMask));
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:35,代碼來源:CMenuItem.java

示例9: setLabel

import java.awt.MenuShortcut; //導入依賴的package包/類
@SuppressWarnings("deprecation")
public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
    int keyMask = modifiers;
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut();

        if (shortcut != null) {
            keyCode = shortcut.getKey();
            keyMask |= InputEvent.META_MASK;

            if (shortcut.usesShiftModifier()) {
                keyMask |= InputEvent.SHIFT_MASK;
            }
        }
    }

    if (label == null) {
        label = "";
    }

    // <rdar://problem/3654824>
    // Native code uses a keyChar of 0 to indicate that the
    // keyCode should be used to generate the shortcut.  Translate
    // CHAR_UNDEFINED into 0.
    if (keyChar == KeyEvent.CHAR_UNDEFINED) {
        keyChar = 0;
    }

    final String finalLabel = label;
    final char finalKeyChar = keyChar;
    final int finalKeyCode = keyCode;
    final int finalKeyMask = keyMask;
    execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar,
                                  finalKeyCode, finalKeyMask));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:36,代碼來源:CMenuItem.java

示例10: addItem

import java.awt.MenuShortcut; //導入依賴的package包/類
public void addItem (MenuItem item)
{
  int key = 0;
  boolean shiftModifier = false;

  MenuShortcut ms = item.getShortcut ();
  if (ms != null)
    {
      key = ms.getKey ();
      shiftModifier = ms.usesShiftModifier ();
    }

  addItem ((MenuItemPeer) item.getPeer (), key, shiftModifier);
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:15,代碼來源:GtkMenuPeer.java

示例11: instantiate

import java.awt.MenuShortcut; //導入依賴的package包/類
@Override
@SuppressWarnings("boxing")
protected Expression instantiate(Object oldInstance, Encoder enc) {
	MenuShortcut shortcut = (MenuShortcut) oldInstance;
	int keyCode = shortcut.getKey();
	boolean useShiftModifier = shortcut.usesShiftModifier();
	return new Expression(shortcut, shortcut.getClass(),
               Statement.CONSTRUCTOR_NAME, new Object[] {keyCode, useShiftModifier});
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:10,代碼來源:AwtMenuShortcutPersistenceDelegate.java

示例12: registerAwtPDs

import java.awt.MenuShortcut; //導入依賴的package包/類
private static void registerAwtPDs() {
	delegates.put(Choice.class, new AwtChoicePersistenceDelegate());
	delegates.put(Color.class, new AwtColorPersistenceDelegate());
	delegates.put(Container.class,
			new AwtContainerPersistenceDelegate());
	delegates.put(Component.class,
			new AwtComponentPersistenceDelegate());
	delegates.put(Cursor.class, new AwtCursorPersistenceDelegate());
	delegates.put(Dimension.class,
			new AwtDimensionPersistenceDelegate());
	delegates.put(Font.class, new AwtFontPersistenceDelegate());
	delegates.put(Insets.class, new AwtInsetsPersistenceDelegate());
	delegates.put(List.class, new AwtListPersistenceDelegate());
	delegates.put(Menu.class, new AwtMenuPersistenceDelegate());
	delegates.put(MenuBar.class, new AwtMenuBarPersistenceDelegate());
	delegates.put(MenuShortcut.class,
			new AwtMenuShortcutPersistenceDelegate());
	delegates.put(Point.class, new AwtPointPersistenceDelegate());
	delegates.put(Rectangle.class,
			new AwtRectanglePersistenceDelegate());
	delegates.put(SystemColor.class,
			new AwtSystemColorPersistenceDelegate());
	delegates.put(TextAttribute.class,
			new AwtFontTextAttributePersistenceDelegate());
	delegates.put(ScrollPane.class,
			new AwtScrollPanePersistenceDelegate());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:28,代碼來源:Encoder.java

示例13: instantiate

import java.awt.MenuShortcut; //導入依賴的package包/類
@Override
protected Expression instantiate(Object oldInstance, Encoder enc)
{
	MenuShortcut shortcut = (MenuShortcut) oldInstance;
	int keyCode = shortcut.getKey();
	boolean useShiftModifier = shortcut.usesShiftModifier();
	return new Expression(shortcut, shortcut.getClass(), BeansUtils.NEW, new Object[] { keyCode, useShiftModifier });
}
 
開發者ID:app55,項目名稱:app55-java,代碼行數:9,代碼來源:AwtMenuShortcutPersistenceDelegate.java

示例14: getMenu

import java.awt.MenuShortcut; //導入依賴的package包/類
private static PopupMenu getMenu()
{
   menu = new PopupMenu(ZAYF_TRAY_TOOLTIP);
   exitItem = new MenuItem("exit", new MenuShortcut('x'));

   menu.add(exitItem);
   return menu;
}
 
開發者ID:davidmason,項目名稱:zayf,代碼行數:9,代碼來源:ZayfTrayIcon.java


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