List of usage examples for java.awt.event KeyEvent VK_A
int VK_A
To view the source code for java.awt.event KeyEvent VK_A.
Click Source Link
From source file:components.MenuSelectionManagerDemo.java
public JMenuBar createMenuBar() { JMenuBar menuBar;//w ww .j a v a 2 s. c o m JMenu menu, submenu; JMenuItem menuItem; JRadioButtonMenuItem rbMenuItem; JCheckBoxMenuItem cbMenuItem; //Create the menu bar. menuBar = new JMenuBar(); //Build the first menu. menu = new JMenu("A Menu"); menu.setMnemonic(KeyEvent.VK_A); menu.getAccessibleContext().setAccessibleDescription("The only menu in this program that has menu items"); menuBar.add(menu); //a group of JMenuItems menuItem = new JMenuItem("A text-only menu item", KeyEvent.VK_T); //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("This doesn't really do anything"); menuItem.addActionListener(this); menu.add(menuItem); ImageIcon icon = createImageIcon("images/middle.gif"); menuItem = new JMenuItem("Both text and icon", icon); menuItem.setMnemonic(KeyEvent.VK_B); menuItem.addActionListener(this); menu.add(menuItem); menuItem = new JMenuItem(icon); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.addActionListener(this); menu.add(menuItem); //a group of radio button menu items menu.addSeparator(); ButtonGroup group = new ButtonGroup(); rbMenuItem = new JRadioButtonMenuItem("A radio button menu item"); rbMenuItem.setSelected(true); rbMenuItem.setMnemonic(KeyEvent.VK_R); group.add(rbMenuItem); rbMenuItem.addActionListener(this); menu.add(rbMenuItem); rbMenuItem = new JRadioButtonMenuItem("Another one"); rbMenuItem.setMnemonic(KeyEvent.VK_O); group.add(rbMenuItem); rbMenuItem.addActionListener(this); menu.add(rbMenuItem); //a group of check box menu items menu.addSeparator(); cbMenuItem = new JCheckBoxMenuItem("A check box menu item"); cbMenuItem.setMnemonic(KeyEvent.VK_C); cbMenuItem.addItemListener(this); menu.add(cbMenuItem); cbMenuItem = new JCheckBoxMenuItem("Another one"); cbMenuItem.setMnemonic(KeyEvent.VK_H); cbMenuItem.addItemListener(this); menu.add(cbMenuItem); //a submenu menu.addSeparator(); submenu = new JMenu("A submenu"); submenu.setMnemonic(KeyEvent.VK_S); menuItem = new JMenuItem("An item in the submenu"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, ActionEvent.ALT_MASK)); menuItem.addActionListener(this); submenu.add(menuItem); menuItem = new JMenuItem("Another item"); menuItem.addActionListener(this); submenu.add(menuItem); menu.add(submenu); //Build second menu in the menu bar. menu = new JMenu("Another Menu"); menu.setMnemonic(KeyEvent.VK_N); menu.getAccessibleContext().setAccessibleDescription("This menu does nothing"); menuBar.add(menu); Timer timer = new Timer(ONE_SECOND, new ActionListener() { public void actionPerformed(ActionEvent evt) { MenuElement[] path = MenuSelectionManager.defaultManager().getSelectedPath(); for (int i = 0; i < path.length; i++) { if (path[i].getComponent() instanceof javax.swing.JMenuItem) { JMenuItem mi = (JMenuItem) path[i].getComponent(); if ("".equals(mi.getText())) { output.append("ICON-ONLY MENU ITEM > "); } else { output.append(mi.getText() + " > "); } } } if (path.length > 0) output.append(newline); } }); timer.start(); return menuBar; }
From source file:MenuDemo.java
public JMenuBar createMenuBar() { JMenuBar menuBar;//from w w w . ja v a 2 s.co m JMenu menu, submenu; JMenuItem menuItem; JRadioButtonMenuItem rbMenuItem; JCheckBoxMenuItem cbMenuItem; //Create the menu bar. menuBar = new JMenuBar(); //Build the first menu. menu = new JMenu("A Menu"); menu.setMnemonic(KeyEvent.VK_A); menu.getAccessibleContext().setAccessibleDescription("The only menu in this program that has menu items"); menuBar.add(menu); //a group of JMenuItems menuItem = new JMenuItem("A text-only menu item", KeyEvent.VK_T); //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("This doesn't really do anything"); menuItem.addActionListener(this); menu.add(menuItem); ImageIcon icon = createImageIcon("images/1.gif"); menuItem = new JMenuItem("Both text and icon", icon); menuItem.setMnemonic(KeyEvent.VK_B); menuItem.addActionListener(this); menu.add(menuItem); menuItem = new JMenuItem(icon); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.addActionListener(this); menu.add(menuItem); //a group of radio button menu items menu.addSeparator(); ButtonGroup group = new ButtonGroup(); rbMenuItem = new JRadioButtonMenuItem("A radio button menu item"); rbMenuItem.setSelected(true); rbMenuItem.setMnemonic(KeyEvent.VK_R); group.add(rbMenuItem); rbMenuItem.addActionListener(this); menu.add(rbMenuItem); rbMenuItem = new JRadioButtonMenuItem("Another one"); rbMenuItem.setMnemonic(KeyEvent.VK_O); group.add(rbMenuItem); rbMenuItem.addActionListener(this); menu.add(rbMenuItem); //a group of check box menu items menu.addSeparator(); cbMenuItem = new JCheckBoxMenuItem("A check box menu item"); cbMenuItem.setMnemonic(KeyEvent.VK_C); cbMenuItem.addItemListener(this); menu.add(cbMenuItem); cbMenuItem = new JCheckBoxMenuItem("Another one"); cbMenuItem.setMnemonic(KeyEvent.VK_H); cbMenuItem.addItemListener(this); menu.add(cbMenuItem); //a submenu menu.addSeparator(); submenu = new JMenu("A submenu"); submenu.setMnemonic(KeyEvent.VK_S); menuItem = new JMenuItem("An item in the submenu"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, ActionEvent.ALT_MASK)); menuItem.addActionListener(this); submenu.add(menuItem); menuItem = new JMenuItem("Another item"); menuItem.addActionListener(this); submenu.add(menuItem); menu.add(submenu); //Build second menu in the menu bar. menu = new JMenu("Another Menu"); menu.setMnemonic(KeyEvent.VK_N); menu.getAccessibleContext().setAccessibleDescription("This menu does nothing"); menuBar.add(menu); return menuBar; }
From source file:org.apache.cassandra.contrib.circuit.CircuitFrame.java
public CircuitFrame(String hostname, int port) { super(appTitle); setSize(defaultSize);//from ww w. j a v a 2 s . co m setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // The menu bar w/ items. menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add(fileMenu); quitMI = new JMenuItem("Quit"); quitMI.setMnemonic(KeyEvent.VK_Q); quitMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, Event.CTRL_MASK)); quitMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); fileMenu.add(quitMI); JMenu toolsMenu = new JMenu("Tools"); toolsMenu.setMnemonic(KeyEvent.VK_T); menuBar.add(toolsMenu); verifyMI = new JMenuItem("Verify Ring"); verifyMI.addActionListener(this); toolsMenu.add(verifyMI); JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic(KeyEvent.VK_H); menuBar.add(helpMenu); aboutMI = new JMenuItem("About"); aboutMI.setMnemonic(KeyEvent.VK_A); aboutMI.addActionListener(this); helpMenu.add(aboutMI); // FIXME: a progress dialog should be up while instantiating RingPanel ringModel = new RingModel(hostname, port); ringPanel = new RingPanel(ringModel); statusOutput = new JTextArea(); statusOutput.setEditable(false); Component logPanel = new JScrollPane(statusOutput); JSplitPane contentPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, ringPanel, logPanel); setContentPane(contentPane); // Order matters here... ringPanel.setPreferredSize(getSize()); setVisible(true); contentPane.setDividerLocation(0.8); }
From source file:MenuSelectionManagerDemo.java
public JMenuBar createMenuBar() { JMenuBar menuBar;/*from w w w . j av a 2 s . c om*/ JMenu menu, submenu; JMenuItem menuItem; JRadioButtonMenuItem rbMenuItem; JCheckBoxMenuItem cbMenuItem; //Create the menu bar. menuBar = new JMenuBar(); //Build the first menu. menu = new JMenu("A Menu"); menu.setMnemonic(KeyEvent.VK_A); menu.getAccessibleContext().setAccessibleDescription("The only menu in this program that has menu items"); menuBar.add(menu); //a group of JMenuItems menuItem = new JMenuItem("A text-only menu item", KeyEvent.VK_T); //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("This doesn't really do anything"); menuItem.addActionListener(this); menu.add(menuItem); ImageIcon icon = createImageIcon("1.gif"); menuItem = new JMenuItem("Both text and icon", icon); menuItem.setMnemonic(KeyEvent.VK_B); menuItem.addActionListener(this); menu.add(menuItem); menuItem = new JMenuItem(icon); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.addActionListener(this); menu.add(menuItem); //a group of radio button menu items menu.addSeparator(); ButtonGroup group = new ButtonGroup(); rbMenuItem = new JRadioButtonMenuItem("A radio button menu item"); rbMenuItem.setSelected(true); rbMenuItem.setMnemonic(KeyEvent.VK_R); group.add(rbMenuItem); rbMenuItem.addActionListener(this); menu.add(rbMenuItem); rbMenuItem = new JRadioButtonMenuItem("Another one"); rbMenuItem.setMnemonic(KeyEvent.VK_O); group.add(rbMenuItem); rbMenuItem.addActionListener(this); menu.add(rbMenuItem); //a group of check box menu items menu.addSeparator(); cbMenuItem = new JCheckBoxMenuItem("A check box menu item"); cbMenuItem.setMnemonic(KeyEvent.VK_C); cbMenuItem.addItemListener(this); menu.add(cbMenuItem); cbMenuItem = new JCheckBoxMenuItem("Another one"); cbMenuItem.setMnemonic(KeyEvent.VK_H); cbMenuItem.addItemListener(this); menu.add(cbMenuItem); //a submenu menu.addSeparator(); submenu = new JMenu("A submenu"); submenu.setMnemonic(KeyEvent.VK_S); menuItem = new JMenuItem("An item in the submenu"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, ActionEvent.ALT_MASK)); menuItem.addActionListener(this); submenu.add(menuItem); menuItem = new JMenuItem("Another item"); menuItem.addActionListener(this); submenu.add(menuItem); menu.add(submenu); //Build second menu in the menu bar. menu = new JMenu("Another Menu"); menu.setMnemonic(KeyEvent.VK_N); menu.getAccessibleContext().setAccessibleDescription("This menu does nothing"); menuBar.add(menu); Timer timer = new Timer(ONE_SECOND, new ActionListener() { public void actionPerformed(ActionEvent evt) { MenuElement[] path = MenuSelectionManager.defaultManager().getSelectedPath(); for (int i = 0; i < path.length; i++) { if (path[i].getComponent() instanceof javax.swing.JMenuItem) { JMenuItem mi = (JMenuItem) path[i].getComponent(); if ("".equals(mi.getText())) { output.append("ICON-ONLY MENU ITEM > "); } else { output.append(mi.getText() + " > "); } } } if (path.length > 0) output.append(newline); } }); timer.start(); return menuBar; }
From source file:be.fedict.eid.tsl.tool.TslTool.java
private void initHelpMenu(JMenuBar menuBar) { JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic(KeyEvent.VK_H); menuBar.add(helpMenu);/*from w w w. jav a 2 s. c o m*/ addActionMenuItem("About", KeyEvent.VK_A, ABOUT_ACTION_COMMAND, helpMenu); }
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 w w . j a v a2 s.c o 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); }
From source file:cz.muni.fi.javaseminar.kafa.bookregister.gui.MainWindow.java
private void initMainWindow() { this.addWindowFocusListener(new WindowAdapter() { @Override//from ww w .ja v a2s . c om public void windowGainedFocus(WindowEvent e) { updateModel(); } }); this.getRootPane().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK), "NEW_AUTHOR"); this.getRootPane().getActionMap().put("NEW_AUTHOR", spawnNewAuthorWindowAction); }
From source file:be.fedict.eid.tsl.tool.TslTool.java
private void initFileMenu(JMenuBar menuBar) { JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add(fileMenu);// w ww. j a v a2s . co m initNewMenu(fileMenu); addActionMenuItem("Open", KeyEvent.VK_O, OPEN_ACTION_COMMAND, fileMenu); fileMenu.addSeparator(); this.signMenuItem = addActionMenuItem("Sign", KeyEvent.VK_S, SIGN_ACTION_COMMAND, fileMenu, false); this.saveMenuItem = addActionMenuItem("Save", KeyEvent.VK_A, SAVE_ACTION_COMMAND, fileMenu, false); this.saveAsMenuItem = addActionMenuItem("Save As", KeyEvent.VK_V, SAVE_AS_ACTION_COMMAND, fileMenu, false); this.exportMenuItem = addActionMenuItem("Export", KeyEvent.VK_E, EXPORT_ACTION_COMMAND, fileMenu, false); this.closeMenuItem = addActionMenuItem("Close", KeyEvent.VK_C, CLOSE_ACTION_COMMAND, fileMenu, false); fileMenu.addSeparator(); addActionMenuItem("Exit", KeyEvent.VK_X, EXIT_ACTION_COMMAND, fileMenu); }
From source file:org.eclipse.jubula.client.ui.rcp.constants.InputCodeHelper.java
/** * private constructor/*from w w w . j a v a 2 s . c om*/ * */ private InputCodeHelper() { m_modifier[0] = InputEvent.CTRL_DOWN_MASK; m_modifier[1] = InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK; m_modifier[2] = InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK; m_modifier[3] = InputEvent.ALT_DOWN_MASK; m_modifier[4] = InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK; m_modifier[5] = 0; // no modifier pressed List<UserInput> inputList = new ArrayList<UserInput>(); List<String> inputStringList = new ArrayList<String>(); for (int i = KeyEvent.VK_0; i <= KeyEvent.VK_9; i++) { inputList.add(new UserInput(i, InputConstants.TYPE_KEY_PRESS)); inputStringList.add(KeyEvent.getKeyText(i)); } for (int i = KeyEvent.VK_A; i <= KeyEvent.VK_Z; i++) { inputList.add(new UserInput(i, InputConstants.TYPE_KEY_PRESS)); inputStringList.add(KeyEvent.getKeyText(i)); } for (int i = KeyEvent.VK_NUMPAD0; i <= KeyEvent.VK_ADD; i++) { inputList.add(new UserInput(i, InputConstants.TYPE_KEY_PRESS)); inputStringList.add(KeyEvent.getKeyText(i)); } for (int i = KeyEvent.VK_SUBTRACT; i <= KeyEvent.VK_DIVIDE; i++) { inputList.add(new UserInput(i, InputConstants.TYPE_KEY_PRESS)); inputStringList.add(KeyEvent.getKeyText(i)); } for (int i = KeyEvent.VK_F1; i <= KeyEvent.VK_F12; i++) { inputList.add(new UserInput(i, InputConstants.TYPE_KEY_PRESS)); inputStringList.add(KeyEvent.getKeyText(i)); } m_modifierString = new String[m_modifier.length]; for (int i = 0; i < m_modifier.length; i++) { m_modifierString[i] = InputEvent.getModifiersExText(m_modifier[i]); } m_keys = inputList.toArray(new UserInput[inputList.size()]); m_keyStrings = inputStringList.toArray(new String[inputStringList.size()]); inputList.add(new UserInput(InputConstants.MOUSE_BUTTON_LEFT, InputConstants.TYPE_MOUSE_CLICK)); inputList.add(new UserInput(InputConstants.MOUSE_BUTTON_MIDDLE, InputConstants.TYPE_MOUSE_CLICK)); inputList.add(new UserInput(InputConstants.MOUSE_BUTTON_RIGHT, InputConstants.TYPE_MOUSE_CLICK)); inputStringList.add(Messages.ObjectMappingPreferencePageMouseButton1); inputStringList.add(Messages.ObjectMappingPreferencePageMouseButton2); inputStringList.add(Messages.ObjectMappingPreferencePageMouseButton3); m_inputs = inputList.toArray(new UserInput[inputList.size()]); m_inputStrings = inputStringList.toArray(new String[inputStringList.size()]); }
From source file:de.pavloff.spark4knime.jsnippet.ui.JarListPanel.java
/** Inits GUI. */ public JarListPanel() { super(new BorderLayout()); m_addJarList = new JList<String>(new DefaultListModel<String>()) { /** {@inheritDoc} */ @Override// w w w . j a va 2 s .c om protected void processComponentKeyEvent(final KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_A && e.isControlDown()) { int end = getModel().getSize() - 1; getSelectionModel().setSelectionInterval(0, end); } else if (e.getKeyCode() == KeyEvent.VK_DELETE) { onJarRemove(); } } }; m_addJarList.setCellRenderer(new ConvenientComboBoxRenderer()); add(new JScrollPane(m_addJarList), BorderLayout.CENTER); JPanel southP = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 5)); m_addJarFilesButton = new JButton("Add File(s)..."); m_addJarFilesButton.addActionListener(new ActionListener() { /** {@inheritDoc} */ @Override public void actionPerformed(final ActionEvent e) { onJarFileAdd(); } }); m_addJarURLsButton = new JButton("Add KNIME URL..."); m_addJarURLsButton.setToolTipText("Add 'knime' URLs that resolve to local paths"); m_addJarURLsButton.addActionListener(new ActionListener() { /** {@inheritDoc} */ @Override public void actionPerformed(final ActionEvent e) { onJarURLAdd(); } }); m_removeButton = new JButton("Remove"); m_removeButton.addActionListener(new ActionListener() { /** {@inheritDoc} */ @Override public void actionPerformed(final ActionEvent e) { onJarRemove(); } }); m_addJarList.addListSelectionListener(new ListSelectionListener() { /** {@inheritDoc} */ @Override public void valueChanged(final ListSelectionEvent e) { m_removeButton.setEnabled(!m_addJarList.isSelectionEmpty()); } }); m_removeButton.setEnabled(!m_addJarList.isSelectionEmpty()); southP.add(m_addJarFilesButton); southP.add(m_addJarURLsButton); southP.add(m_removeButton); add(southP, BorderLayout.SOUTH); JPanel northP = new JPanel(new FlowLayout()); JLabel label = new JLabel("<html><body>Specify additional jar files " + "that are necessary for the snippet to run</body></html>"); northP.add(label); add(northP, BorderLayout.NORTH); }