当前位置: 首页>>代码示例>>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;未经允许,请勿转载。