List of usage examples for javax.swing JMenu setMnemonic
@BeanProperty(visualUpdate = true, description = "the keyboard character mnemonic") public void setMnemonic(int mnemonic)
From source file:uk.co.petertribble.jkstat.gui.KstatBaseChartFrame.java
/** * Create the File... Menu./* w w w . j a v a 2s . co m*/ * * @return the File Menu */ protected JMenu fileMenu() { JMenu jme = new JMenu(KstatResources.getString("FILE.TEXT")); jme.setMnemonic(KeyEvent.VK_F); saveItem = new JMenuItem(KstatResources.getString("FILE.SAVEAS.TEXT"), KeyEvent.VK_S); saveItem.addActionListener(this); jme.add(saveItem); jme.addSeparator(); exitItem = new JMenuItem(KstatResources.getString("FILE.CLOSE.TEXT"), KeyEvent.VK_C); exitItem.addActionListener(this); jme.add(exitItem); return jme; }
From source file:uk.co.petertribble.jkstat.gui.KstatBaseChartFrame.java
/** * Create the Statistics Menu, showing all available statistics for the * chosen ChartableKstat./* w ww . java 2s. co m*/ * * @param cks the Kstat to show the statistics of in the menu * @param statistic the initial statistic, which will be checked * * @return the Statistics Menu */ protected JMenu statisticsMenu(ChartableKstat cks, String statistic) { JMenu jmstat = new JMenu(KstatResources.getString("CHART.SHOW")); jmstat.setMnemonic(KeyEvent.VK_S); for (String stat : cks.getStatistics()) { JCheckBoxMenuItem jmi = new JCheckBoxMenuItem(stat, stat.equals(statistic)); jmi.addActionListener(this); jmstat.add(jmi); } return jmstat; }
From source file:uk.co.petertribble.jkstat.gui.KstatBaseChartFrame.java
/** * Create the Statistics Menu, showing all available statistics for the * chosen ChartableKstat./* w w w . ja v a2s. c o m*/ * * @param cks the ChartableKstat to show the statistics of in the menu * @param statistics the initial statistics, which will be checked * * @return the Statistics Menu */ protected JMenu statisticsMenu(ChartableKstat cks, List<String> statistics) { JMenu jmstat = new JMenu(KstatResources.getString("CHART.SHOW")); jmstat.setMnemonic(KeyEvent.VK_S); for (String stat : cks.getStatistics()) { JCheckBoxMenuItem jmi = new JCheckBoxMenuItem(stat, statistics.contains(stat)); jmi.addActionListener(this); jmstat.add(jmi); } return jmstat; }
From source file:uk.co.petertribble.jkstat.gui.KstatBaseChartFrame.java
/** * Create the Sleep for... Menu.//from w w w. j av a 2 s. c o m * * @return the Sleep Menu */ protected JMenu sleepMenu() { JMenu jms = new JMenu(KstatResources.getString("SLEEP.TEXT")); jms.setMnemonic(KeyEvent.VK_U); sleepItem1 = new JRadioButtonMenuItem(KstatResources.getString("SLEEP.1")); sleepItem1.addActionListener(this); sleepItem2 = new JRadioButtonMenuItem(KstatResources.getString("SLEEP.2")); sleepItem2.addActionListener(this); sleepItem5 = new JRadioButtonMenuItem(KstatResources.getString("SLEEP.5"), true); sleepItem5.addActionListener(this); sleepItem10 = new JRadioButtonMenuItem(KstatResources.getString("SLEEP.10")); sleepItem10.addActionListener(this); jms.add(sleepItem1); jms.add(sleepItem2); jms.add(sleepItem5); jms.add(sleepItem10); ButtonGroup sleepGroup = new ButtonGroup(); sleepGroup.add(sleepItem1); sleepGroup.add(sleepItem2); sleepGroup.add(sleepItem5); sleepGroup.add(sleepItem10); return jms; }
From source file:DragColorTextFieldDemo.java
public JMenuBar createMenuBar() { JMenuItem menuItem = null;/* ww w.j a va2s . co m*/ JMenuBar menuBar = new JMenuBar(); JMenu mainMenu = new JMenu("Edit"); mainMenu.setMnemonic(KeyEvent.VK_E); menuItem = new JMenuItem(new DefaultEditorKit.CutAction()); menuItem.setText("Cut"); menuItem.setMnemonic(KeyEvent.VK_T); mainMenu.add(menuItem); menuItem = new JMenuItem(new DefaultEditorKit.CopyAction()); menuItem.setText("Copy"); menuItem.setMnemonic(KeyEvent.VK_C); mainMenu.add(menuItem); menuItem = new JMenuItem(new DefaultEditorKit.PasteAction()); menuItem.setText("Paste"); menuItem.setMnemonic(KeyEvent.VK_P); mainMenu.add(menuItem); menuBar.add(mainMenu); return menuBar; }
From source file:ListCutPaste.java
/** * Create an Edit menu to support cut/copy/paste. *///from w w w . j a v a 2 s . c o m public JMenuBar createMenuBar() { JMenuItem menuItem = null; JMenuBar menuBar = new JMenuBar(); JMenu mainMenu = new JMenu("Edit"); mainMenu.setMnemonic(KeyEvent.VK_E); TransferActionListener actionListener = new TransferActionListener(); menuItem = new JMenuItem("Cut"); menuItem.setActionCommand((String) TransferHandler.getCutAction().getValue(Action.NAME)); menuItem.addActionListener(actionListener); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK)); menuItem.setMnemonic(KeyEvent.VK_T); mainMenu.add(menuItem); menuItem = new JMenuItem("Copy"); menuItem.setActionCommand((String) TransferHandler.getCopyAction().getValue(Action.NAME)); menuItem.addActionListener(actionListener); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK)); menuItem.setMnemonic(KeyEvent.VK_C); mainMenu.add(menuItem); menuItem = new JMenuItem("Paste"); menuItem.setActionCommand((String) TransferHandler.getPasteAction().getValue(Action.NAME)); menuItem.addActionListener(actionListener); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK)); menuItem.setMnemonic(KeyEvent.VK_P); mainMenu.add(menuItem); menuBar.add(mainMenu); return menuBar; }
From source file:qmod.generator.MainWindow.java
@SuppressWarnings("unchecked") public MainWindow() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setTitle("Quick Mod Generator"); JLabel lblAuthors = new JLabel("Authors:"); authorField1 = new JTextField(); authorField1.setColumns(25);//from www .jav a2s. c o m JButton btnGenerateFile = new JButton("Generate File"); btnGenerateFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { writeFiles(); } }); authCombo1.setFont(new Font("Dialog", Font.BOLD, 8)); authCombo1.setModel( (ComboBoxModel<Object>) new DefaultComboBoxModel<Object>(new String[] { "Author", "Maintainer" })); authCombo1.setSelectedIndex(0); authCombo2.setFont(new Font("Dialog", Font.BOLD, 8)); authCombo2.setModel( (ComboBoxModel<Object>) new DefaultComboBoxModel<Object>(new String[] { "Author", "Maintainer" })); authCombo2.setSelectedIndex(0); authorField2 = new JTextField(); authorField2.setColumns(25); authCombo3.setFont(new Font("Dialog", Font.BOLD, 8)); authCombo3.setModel( (ComboBoxModel<Object>) new DefaultComboBoxModel<Object>(new String[] { "Author", "Maintainer" })); authCombo3.setSelectedIndex(0); authorField3 = new JTextField(); authorField3.setColumns(25); JLabel lblCategories = new JLabel("Categories:"); categoriesField = new JTextField(); categoriesField.setColumns(10); JLabel lblDescription = new JLabel("Description:"); JEditorPane descriptionField = new JEditorPane(); JLabel lblLicense = new JLabel("License:"); licenseField = new JTextField(); licenseField.setColumns(10); GroupLayout groupLayout = new GroupLayout(getContentPane()); groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(groupLayout.createSequentialGroup().addContainerGap() .addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout .createSequentialGroup() .addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout .createParallelGroup(Alignment.TRAILING).addComponent(btnGenerateFile) .addGroup(groupLayout.createSequentialGroup().addComponent(lblAuthors) .addPreferredGap(ComponentPlacement.RELATED).addGroup(groupLayout .createParallelGroup(Alignment.LEADING).addGroup(groupLayout .createSequentialGroup() .addComponent( authCombo2, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE) .addGap(6).addComponent(authorField2, GroupLayout.PREFERRED_SIZE, 192, GroupLayout.PREFERRED_SIZE)) .addGroup(groupLayout.createSequentialGroup().addComponent( authCombo1, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE).addPreferredGap( ComponentPlacement.RELATED) .addComponent( authorField1, GroupLayout.DEFAULT_SIZE, 264, Short.MAX_VALUE)) .addGroup(groupLayout.createSequentialGroup() .addComponent(authCombo3, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE) .addGap(6).addGroup(groupLayout.createParallelGroup( Alignment.LEADING).addComponent( descriptionField) .addGroup(groupLayout .createParallelGroup( Alignment.LEADING, false) .addComponent(categoriesField) .addComponent( authorField3, GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)) .addGroup(groupLayout .createSequentialGroup() .addComponent(licenseField, GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE) .addPreferredGap( ComponentPlacement.RELATED))))))) .addComponent(lblCategories).addComponent(lblDescription)) .addGap(84)) .addGroup(groupLayout.createSequentialGroup().addComponent(lblLicense) .addContainerGap(377, Short.MAX_VALUE))))); groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout .createSequentialGroup().addContainerGap() .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(lblAuthors) .addComponent(authorField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(authCombo1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addComponent(authCombo2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGroup(groupLayout.createSequentialGroup().addGap(3).addComponent(authorField2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addComponent(authCombo3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGroup(groupLayout.createSequentialGroup().addGap(3).addComponent(authorField3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addComponent(lblCategories) .addComponent(categoriesField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addComponent(lblDescription) .addComponent(descriptionField, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)) .addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(groupLayout.createSequentialGroup().addGap(9).addComponent(lblLicense)) .addGroup(groupLayout.createSequentialGroup().addPreferredGap(ComponentPlacement.RELATED) .addComponent(licenseField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addPreferredGap(ComponentPlacement.RELATED, 322, Short.MAX_VALUE).addComponent(btnGenerateFile) .addContainerGap())); getContentPane().setLayout(groupLayout); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu mnFile = new JMenu("File"); mnFile.setMnemonic('F'); menuBar.add(mnFile); JMenuItem mntmNew = new JMenuItem("New"); mntmNew.setMnemonic(KeyEvent.VK_N); mnFile.add(mntmNew); JMenuItem mntmOpen = new JMenuItem("Open"); mnFile.add(mntmOpen); JMenuItem mntmSave = new JMenuItem("Save"); mnFile.add(mntmSave); JMenuItem mntmExit = new JMenuItem("Exit"); mntmExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.exit(0); } }); mntmExit.setMnemonic(KeyEvent.VK_X); mnFile.add(mntmExit); }
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.j ava 2 s. c o m*/ addActionMenuItem("About", KeyEvent.VK_A, ABOUT_ACTION_COMMAND, helpMenu); }
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 w w . ja va 2s. c o 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:edu.harvard.mcz.imagecapture.BulkMediaFrame.java
private void init() { thisFrame = this; setTitle("BulkMedia Preparation"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 902, 174);// ww w .j av a 2 s.com JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu mnFile = new JMenu("File"); mnFile.setMnemonic(KeyEvent.VK_F); menuBar.add(mnFile); JMenuItem mntmPrepareDirectory = new JMenuItem("Prepare Directory"); mntmPrepareDirectory.setMnemonic(KeyEvent.VK_D); mntmPrepareDirectory.addActionListener(new PrepareDirectoryAction()); mnFile.add(mntmPrepareDirectory); JMenuItem mntmNewMenuItem = new JMenuItem("Exit"); mntmNewMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { done(); } }); JMenuItem mntmNewMenuItem_1 = new JMenuItem("Edit Properties"); mntmNewMenuItem_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { PropertiesEditor p = new PropertiesEditor(); p.pack(); p.setVisible(true); } }); mnFile.add(mntmNewMenuItem_1); mntmNewMenuItem.setMnemonic(KeyEvent.VK_X); mntmNewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK)); mnFile.add(mntmNewMenuItem); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(new BorderLayout(0, 0)); JPanel panel = new JPanel(); contentPane.add(panel, BorderLayout.CENTER); panel.setLayout(new GridLayout(3, 2, 0, 0)); JLabel lblBaseUri = new JLabel("Base URI (first part of path to images on the web)"); lblBaseUri.setHorizontalAlignment(SwingConstants.TRAILING); panel.add(lblBaseUri, "2, 2"); textField = new JTextField(); textField.setEditable(false); textField.setText(Singleton.getSingletonInstance().getProperties().getProperties() .getProperty(ImageCaptureProperties.KEY_IMAGEBASEURI)); panel.add(textField); textField.setColumns(10); JLabel lblNewLabel = new JLabel("Local Path To Base (local mount path that maps to base URI)"); lblNewLabel.setHorizontalAlignment(SwingConstants.TRAILING); panel.add(lblNewLabel); textField_1 = new JTextField(); textField_1.setEditable(false); textField_1.setText(Singleton.getSingletonInstance().getProperties().getProperties() .getProperty(ImageCaptureProperties.KEY_IMAGEBASE)); panel.add(textField_1); textField_1.setColumns(10); JLabel lblBeforeExitingWait = new JLabel( "Before exiting wait for both the Done and Thumbnails Built messages."); panel.add(lblBeforeExitingWait); JLabel lblThumbnailGenerationIs = new JLabel("Thumbnail generation is not reported on the progress bar."); panel.add(lblThumbnailGenerationIs); progressBar = new JProgressBar(); progressBar.setStringPainted(false); contentPane.add(progressBar, BorderLayout.NORTH); JPanel panel_1 = new JPanel(); contentPane.add(panel_1, BorderLayout.SOUTH); JButton btnPrepareDirectory = new JButton("Run"); btnPrepareDirectory.setToolTipText("Select a directory and prepare a bulk media file for images therein."); panel_1.add(btnPrepareDirectory); btnPrepareDirectory.addActionListener(new PrepareDirectoryAction()); btnPrepareDirectory.setPreferredSize(new Dimension(80, 25)); JButton btnExit = new JButton("Exit"); btnExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { done(); } }); panel_1.add(btnExit); }