List of usage examples for javax.swing AbstractButton setMnemonic
@BeanProperty(visualUpdate = true, description = "the keyboard character mnemonic") public void setMnemonic(char mnemonic)
setMnemonic(int)
to set the mnemonic for a button. From source file:pcgen.gui2.converter.panel.WriteDirectoryPanel.java
@Override public void setupDisplay(JPanel panel, final CDOMObject pc) { panel.setLayout(layout);/*w ww .j a v a 2s .c o m*/ Component label = new JLabel("Please select the Directory where Converted files should be written: "); AbstractButton button = new JButton("Browse..."); button.setMnemonic('r'); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setDialogType(JFileChooser.OPEN_DIALOG); chooser.setCurrentDirectory(path.getParentFile()); chooser.setSelectedFile(path); while (true) { int open = chooser.showOpenDialog(null); if (open == JFileChooser.APPROVE_OPTION) { File fileToOpen = chooser.getSelectedFile(); if (fileToOpen.isDirectory() && fileToOpen.canRead() && fileToOpen.canWrite()) { path = fileToOpen; pc.put(ObjectKey.WRITE_DIRECTORY, path); fileLabel.setText(path.getAbsolutePath()); PCGenSettings context = PCGenSettings.getInstance(); context.setProperty(PCGenSettings.CONVERT_OUTPUT_SAVE_PATH, path.getAbsolutePath()); showWarning(); break; } JOptionPane.showMessageDialog(null, "Selection must be a valid " + "(readable & writeable) Directory"); chooser.setCurrentDirectory(path.getParentFile()); } else if (open == JFileChooser.CANCEL_OPTION) { break; } } } }); panel.add(label); panel.add(fileLabel); panel.add(button); panel.add(warningLabel); showWarning(); layout.putConstraint(SpringLayout.NORTH, label, 50, SpringLayout.NORTH, panel); layout.putConstraint(SpringLayout.NORTH, fileLabel, 75 + label.getPreferredSize().height, SpringLayout.NORTH, panel); layout.putConstraint(SpringLayout.NORTH, button, 75 + label.getPreferredSize().height, SpringLayout.NORTH, panel); layout.putConstraint(SpringLayout.WEST, label, 25, SpringLayout.WEST, panel); layout.putConstraint(SpringLayout.WEST, fileLabel, 25, SpringLayout.WEST, panel); layout.putConstraint(SpringLayout.EAST, button, -50, SpringLayout.EAST, panel); layout.putConstraint(SpringLayout.NORTH, warningLabel, 20, SpringLayout.SOUTH, fileLabel); layout.putConstraint(SpringLayout.WEST, warningLabel, 25, SpringLayout.WEST, panel); fileLabel.setText(path.getAbsolutePath()); }