Example usage for java.awt.event KeyEvent VK_N

List of usage examples for java.awt.event KeyEvent VK_N

Introduction

In this page you can find the example usage for java.awt.event KeyEvent VK_N.

Prototype

int VK_N

To view the source code for java.awt.event KeyEvent VK_N.

Click Source Link

Document

Constant for the "N" key.

Usage

From source file:Main.java

/**
 * Returns the mnemonic integer.//  ww  w  .j ava 2s . com
 * 
 * @param c The character (uppercase)
 * @return The mnemonic.
 */
@SuppressWarnings("incomplete-switch")
private static int setMnemonicsGet(char c) {
    int mnemonic = 0;
    switch (Character.toUpperCase(c)) {
    case '0':
        mnemonic = KeyEvent.VK_0;
        break;
    case '1':
        mnemonic = KeyEvent.VK_1;
        break;
    case '2':
        mnemonic = KeyEvent.VK_2;
        break;
    case '3':
        mnemonic = KeyEvent.VK_3;
        break;
    case '4':
        mnemonic = KeyEvent.VK_4;
        break;
    case '5':
        mnemonic = KeyEvent.VK_5;
        break;
    case '6':
        mnemonic = KeyEvent.VK_6;
        break;
    case '7':
        mnemonic = KeyEvent.VK_7;
        break;
    case '8':
        mnemonic = KeyEvent.VK_8;
        break;
    case '9':
        mnemonic = KeyEvent.VK_9;
        break;
    case 'A':
        mnemonic = KeyEvent.VK_A;
        break;
    case 'B':
        mnemonic = KeyEvent.VK_B;
        break;
    case 'C':
        mnemonic = KeyEvent.VK_C;
        break;
    case 'D':
        mnemonic = KeyEvent.VK_D;
        break;
    case 'E':
        mnemonic = KeyEvent.VK_E;
        break;
    case 'F':
        mnemonic = KeyEvent.VK_F;
        break;
    case 'G':
        mnemonic = KeyEvent.VK_G;
        break;
    case 'H':
        mnemonic = KeyEvent.VK_H;
        break;
    case 'I':
        mnemonic = KeyEvent.VK_I;
        break;
    case 'J':
        mnemonic = KeyEvent.VK_J;
        break;
    case 'K':
        mnemonic = KeyEvent.VK_K;
        break;
    case 'L':
        mnemonic = KeyEvent.VK_L;
        break;
    case 'M':
        mnemonic = KeyEvent.VK_M;
        break;
    case 'N':
        mnemonic = KeyEvent.VK_N;
        break;
    case 'O':
        mnemonic = KeyEvent.VK_O;
        break;
    case 'P':
        mnemonic = KeyEvent.VK_P;
        break;
    case 'Q':
        mnemonic = KeyEvent.VK_Q;
        break;
    case 'R':
        mnemonic = KeyEvent.VK_R;
        break;
    case 'S':
        mnemonic = KeyEvent.VK_S;
        break;
    case 'T':
        mnemonic = KeyEvent.VK_T;
        break;
    case 'U':
        mnemonic = KeyEvent.VK_U;
        break;
    case 'V':
        mnemonic = KeyEvent.VK_V;
        break;
    case 'W':
        mnemonic = KeyEvent.VK_W;
        break;
    case 'X':
        mnemonic = KeyEvent.VK_X;
        break;
    case 'Y':
        mnemonic = KeyEvent.VK_Y;
        break;
    case 'Z':
        mnemonic = KeyEvent.VK_Z;
        break;
    }
    return mnemonic;
}

From source file:ca.sfu.federation.action.CreateProjectAction.java

/**
 * CreateProjectAction default constructor.
 *///from  w w w  . j  a v a  2  s.c  om
public CreateProjectAction() {
    super("New Project", null);
    Icon icon = ImageIconUtils.loadIconById("file-new-project-icon");
    this.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control shift N"));
    this.putValue(Action.LONG_DESCRIPTION, "Create a new project");
    this.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_N);
    this.putValue(Action.SHORT_DESCRIPTION, "Create a new project");
    this.putValue(Action.SMALL_ICON, icon);
}

From source file:uk.nhs.cfh.dsp.srth.desktop.actions.querycrud.core.actions.NewQueryAction.java

/**
 * Instantiates a new new query action.//from  ww  w .j  a v  a  2s  .  c o  m
 *
 * @param applicationService the application service
 * @param queryService the query service
 * @param queryExpressionFactory the query expression factory
 */
public NewQueryAction(ApplicationService applicationService, QueryService queryService,
        QueryExpressionFactory queryExpressionFactory) {
    super("New Query", new ImageIcon(NewQueryAction.class.getResource("resources/filenew.png")));
    this.applicationService = applicationService;
    this.queryService = queryService;
    this.queryExpressionFactory = queryExpressionFactory;
    putValue(ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    putValue(SHORT_DESCRIPTION, "Create new query");
    putValue(LONG_DESCRIPTION, "Creates a new query and sets it to active query");
}

From source file:com.evanbelcher.DrillBook.display.DBMenuBar.java

/**
 * Constructs DBMenuBar. Adds the menu and menuitems.
 *
 * @param graphicsRunner the JFrame that created this
 * @param desktop        the DBDesktopPane in the JFrame
 *///from w  w  w  . ja  va 2s  . co m
public DBMenuBar(GraphicsRunner graphicsRunner, DBDesktopPane desktop) {
    super();

    gr = graphicsRunner;
    this.desktop = desktop;

    //Set up the menu
    JMenu menu = new JMenu("File");
    add(menu);

    //Set up the menu items.
    JMenuItem menuItem = new JMenuItem("New");
    menuItem.setMnemonic(KeyEvent.VK_N);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("new");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Open");
    menuItem.setMnemonic(KeyEvent.VK_O);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("open");
    menuItem.addActionListener(this);
    menuItem.setLayout(new MigLayout());
    menu.add(menuItem);

    menuItem = new JMenuItem("Save");
    menuItem.setMnemonic(KeyEvent.VK_S);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("save");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Save As");
    menuItem.setActionCommand("saveas");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Print    Current Page");
    menuItem.setMnemonic(KeyEvent.VK_P);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("printpage");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Print Show");
    menuItem.setActionCommand("printshow");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Print Dot Sheets");
    menuItem.setActionCommand("printdotsheets");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Quit");
    menuItem.setMnemonic(KeyEvent.VK_Q);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("quit");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menu = new JMenu("Edit");
    add(menu);

    menuItem = new JMenuItem("Undo");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("undo");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Redo");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("redo");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menu = new JMenu("Settings");
    add(menu);

    menuItem = new JMenuItem("Toggle Gridlines");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("togglegrid");
    menuItem.addActionListener(this);
    menuItem.setForeground(Main.getState().getSettings().shouldShowGrid() ? Color.BLACK : Color.RED);
    menu.add(menuItem);

    menuItem = new JMenuItem("Toggle Dot Names");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK));
    menuItem.setActionCommand("togglenames");
    menuItem.addActionListener(this);
    menuItem.setForeground(Main.getState().getSettings().shouldShowNames() ? Color.BLACK : Color.RED);
    menu.add(menuItem);

    menuItem = new JMenuItem("Toggle Text Box");
    menuItem.setActionCommand("toggletext");
    menuItem.addActionListener(this);
    menuItem.setForeground(Main.getState().getSettings().shouldShowText() ? Color.BLACK : Color.RED);
    menu.add(menuItem);

    menuItem = new JMenuItem("Color Code Dots by Instrument");
    menuItem.setActionCommand("colordots");
    menuItem.addActionListener(this);
    menuItem.setForeground(Main.getState().getSettings().shouldColorDots() ? Color.BLACK : Color.RED);
    menu.add(menuItem);

    menuItem = new JMenuItem();
    menuItem.setText(Main.getState().getSettings().useCollegeHashes() ? "Change to High School Hashes"
            : "Change to College Hashes");
    menuItem.setActionCommand("changehash");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("Change Font Size");
    menuItem.setActionCommand("fontsize");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    //add(Box.createHorizontalStrut(menu.getPreferredSize().width));

    //add these to the menubar itself
    menuItem = new JMenuItem("Play");
    menuItem.setMaximumSize(new Dimension(menuItem.getPreferredSize().width, Integer.MAX_VALUE));
    menuItem.setActionCommand("play");
    menuItem.addActionListener(this);
    add(menuItem);

    add(Box.createHorizontalGlue());

    menu = new JMenu("Help");
    add(menu);

    menuItem = new JMenuItem("Help");
    menuItem.setActionCommand("help");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem("About");
    menuItem.setActionCommand("about");
    menuItem.addActionListener(this);
    menu.add(menuItem);
}

From source file:de.tor.tribes.ui.components.GroupSelectionList.java

public GroupSelectionList(String pResourceURL) {
    super(pResourceURL);

    setCellRenderer(renderer);//w  w w  .j  a  va2  s .co  m

    addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_LEFT) {
                fireDecrementEvent();
            } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
                fireIncrementEvent();
            } else if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                fireResetEvent();
            } else if (e.getKeyCode() == KeyEvent.VK_O) {
                fireSetStateEvent(ListItem.RELATION_TYPE.OR);
            } else if (e.getKeyCode() == KeyEvent.VK_U) {
                fireSetStateEvent(ListItem.RELATION_TYPE.AND);
            } else if (e.getKeyCode() == KeyEvent.VK_N) {
                fireSetStateEvent(ListItem.RELATION_TYPE.NOT);
            } else if (e.getKeyCode() == KeyEvent.VK_I) {
                fireSetStateEvent(ListItem.RELATION_TYPE.DISABLED);
            } else if (e.getKeyCode() == KeyEvent.VK_H) {
                JOptionPaneHelper.showInformationBox(GroupSelectionList.this, getRelationAsPlainText(),
                        "Information");
            }
        }
    });
    addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                if (e.getButton() == MouseEvent.BUTTON1) {
                    fireClickedEvent(e.getPoint());
                } else {
                    fireResetEvent(e.getPoint());
                }
            }
        }
    });
    TagManager.getSingleton().addManagerListener(GroupSelectionList.this);
}

From source file:components.InternalFrameDemo.java

protected JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();

    //Set up the lone menu.
    JMenu menu = new JMenu("Document");
    menu.setMnemonic(KeyEvent.VK_D);
    menuBar.add(menu);//  ww w  .  jav  a2 s.  c om

    //Set up the first menu item.
    JMenuItem menuItem = new JMenuItem("New");
    menuItem.setMnemonic(KeyEvent.VK_N);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.ALT_MASK));
    menuItem.setActionCommand("new");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    //Set up the second menu item.
    menuItem = new JMenuItem("Quit");
    menuItem.setMnemonic(KeyEvent.VK_Q);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.ALT_MASK));
    menuItem.setActionCommand("quit");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    return menuBar;
}

From source file:InternalFrameDemo.java

protected JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();

    // Set up the lone menu.
    JMenu menu = new JMenu("Document");
    menu.setMnemonic(KeyEvent.VK_D);
    menuBar.add(menu);/*from ww w.j a  va 2 s .  co m*/

    // Set up the first menu item.
    JMenuItem menuItem = new JMenuItem("New");
    menuItem.setMnemonic(KeyEvent.VK_N);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.ALT_MASK));
    menuItem.setActionCommand("new");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    // Set up the second menu item.
    menuItem = new JMenuItem("Quit");
    menuItem.setMnemonic(KeyEvent.VK_Q);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.ALT_MASK));
    menuItem.setActionCommand("quit");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    return menuBar;
}

From source file:org.pmedv.blackboard.commands.CreateBoardCommand.java

public CreateBoardCommand() {
    title = "untitled";
    putValue(Action.NAME, resources.getResourceByKey("CreateBoardCommand.name"));
    putValue(Action.SMALL_ICON, resources.getIcon("icon.new"));
    putValue(Action.SHORT_DESCRIPTION, resources.getResourceByKey("CreateBoardCommand.description"));
    putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK));
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.PeakAnnotationReportPanel.java

protected void createActions() {

    theActionManager.add("new", FileUtils.defaultThemeManager.getImageIcon("new"), "Clear", KeyEvent.VK_N, "",
            this);
    theActionManager.add("print", FileUtils.defaultThemeManager.getImageIcon("print"), "Print...",
            KeyEvent.VK_P, "", this);
}

From source file:org.renjin.studio.MainFrame.java

private void setupMenu() {
    //Create the menu bar.
    JMenuBar menuBar = new JMenuBar();

    //Build the first menu.
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_A);
    menuBar.add(fileMenu);//from  w ww. ja v a 2  s .co m

    JMenu newMenu = new JMenu("New");
    newMenu.setMnemonic(KeyEvent.VK_N);

    JMenuItem newScriptItem = new JMenuItem("R Script");
    newMenu.add(newScriptItem);

    fileMenu.add(newMenu);

    setJMenuBar(menuBar);
}