本文整理汇总了Java中javax.swing.JButton.setMnemonic方法的典型用法代码示例。如果您正苦于以下问题:Java JButton.setMnemonic方法的具体用法?Java JButton.setMnemonic怎么用?Java JButton.setMnemonic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JButton
的用法示例。
在下文中一共展示了JButton.setMnemonic方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showUpgradeDialog
import javax.swing.JButton; //导入方法依赖的package包/类
private static boolean showUpgradeDialog (final File source, String note) {
Util.setDefaultLookAndFeel();
JPanel panel = new JPanel(new BorderLayout());
panel.add(new AutoUpgradePanel (source.getAbsolutePath (), note), BorderLayout.CENTER);
JProgressBar progressBar = new JProgressBar(0, 100);
progressBar.setValue(0);
progressBar.setStringPainted(true);
progressBar.setIndeterminate(true);
panel.add(progressBar, BorderLayout.SOUTH);
progressBar.setVisible(false);
JButton bYES = new JButton("Yes");
bYES.setMnemonic(KeyEvent.VK_Y);
JButton bNO = new JButton("No");
bNO.setMnemonic(KeyEvent.VK_N);
JButton[] options = new JButton[] {bYES, bNO};
JOptionPane p = new JOptionPane (panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options, bYES);
JDialog d = Util.createJOptionProgressDialog(p, NbBundle.getMessage (AutoUpgrade.class, "MSG_Confirmation_Title"), source, progressBar);
d.setVisible (true);
return new Integer (JOptionPane.YES_OPTION).equals (p.getValue ());
}
示例2: getGridButton
import javax.swing.JButton; //导入方法依赖的package包/类
/** Gets grid button.*/
private JButton getGridButton() {
// PENDING buttons should have their own icons.
final JButton button = new JButton(" # "); // NOI18N
button.setToolTipText (NbBundle.getBundle(ImageViewer.class).getString("LBL_ShowHideGrid"));
button.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(ImageViewer.class).getString("ACS_Grid_BTN"));
button.setMnemonic(NbBundle.getBundle(ImageViewer.class).getString("ACS_Grid_BTN_Mnem").charAt(0));
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
showGrid = !showGrid;
panel.repaint(0, 0, panel.getWidth(), panel.getHeight());
}
});
return button;
}
示例3: buttonPanel
import javax.swing.JButton; //导入方法依赖的package包/类
private Component buttonPanel() {
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
accept = new JButton("Accept");
accept.setFont(new Font("Arial", Font.PLAIN, 14));
accept.setPreferredSize(new Dimension(110, 30));
accept.setMnemonic(KeyEvent.VK_A);
accept.setActionCommand("accept");
accept.addActionListener(this);
JButton cancel = new JButton("Cancel");
cancel.setFont(new Font("Arial", Font.PLAIN, 14));
cancel.setPreferredSize(new Dimension(110, 30));
cancel.setMnemonic(KeyEvent.VK_C);
cancel.setActionCommand("cancel");
cancel.addActionListener(this);
panel.add(accept);
panel.add(Box.createRigidArea(new Dimension(50, 0)));
panel.add(cancel);
return panel;
}
示例4: createButton
import javax.swing.JButton; //导入方法依赖的package包/类
private JButton createButton(String title, char mnemonic, boolean focusable) {
JButton currentButton = new JButton(title);
currentButton.setMnemonic(mnemonic);
currentButton.setFocusable(focusable);
currentButton.addActionListener(acheck);
return currentButton;
}
示例5: searchClassFiles
import javax.swing.JButton; //导入方法依赖的package包/类
private void searchClassFiles(File[] folders) throws WizardValidationException {
List<File> classFiles = new ArrayList<File>();
for (File folder : folders) {
findClassFiles(folder, classFiles);
}
if (!classFiles.isEmpty()) {
JButton DELETE_OPTION = new JButton(NbBundle.getMessage(PanelSourceFolders.class, "TXT_DeleteOption")); // NOI18N
JButton KEEP_OPTION = new JButton(NbBundle.getMessage(PanelSourceFolders.class, "TXT_KeepOption")); // NOI18N
JButton CANCEL_OPTION = new JButton(NbBundle.getMessage(PanelSourceFolders.class, "TXT_CancelOption")); // NOI18N
KEEP_OPTION.setMnemonic(NbBundle.getMessage(PanelSourceFolders.class, "MNE_KeepOption").charAt(0)); // NOI18N
DELETE_OPTION.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PanelSourceFolders.class, "AD_DeleteOption")); // NOI18N
KEEP_OPTION.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PanelSourceFolders.class, "AD_KeepOption")); // NOI18N
CANCEL_OPTION.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PanelSourceFolders.class, "AD_CancelOption")); // NOI18N
NotifyDescriptor desc = new NotifyDescriptor(
NbBundle.getMessage(PanelSourceFolders.class, "MSG_FoundClassFiles"), // NOI18N
NbBundle.getMessage(PanelSourceFolders.class, "MSG_FoundClassFiles_Title"), // NOI18N
NotifyDescriptor.YES_NO_CANCEL_OPTION,
NotifyDescriptor.QUESTION_MESSAGE,
new Object[]{DELETE_OPTION, KEEP_OPTION, CANCEL_OPTION},
DELETE_OPTION);
Object result = DialogDisplayer.getDefault().notify(desc);
if (DELETE_OPTION.equals(result)) {
for (File f : classFiles) {
f.delete(); // ignore if fails
}
} else if (!KEEP_OPTION.equals(result)) {
// cancel, back to wizard
throw new WizardValidationException(this.sourcePanel, "", ""); // NOI18N
}
}
}
示例6: canCloseImpl
import javax.swing.JButton; //导入方法依赖的package包/类
/** @return 0 => cannot close, -1 can close and do not save, 1 can close and save */
private int canCloseImpl() {
String msg = messageSave();
ResourceBundle bundle = NbBundle.getBundle(CloneableEditorSupport.class);
JButton saveOption = new JButton(bundle.getString("CTL_Save")); // NOI18N
saveOption.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_CTL_Save")); // NOI18N
saveOption.getAccessibleContext().setAccessibleName(bundle.getString("ACSN_CTL_Save")); // NOI18N
JButton discardOption = new JButton(bundle.getString("CTL_Discard")); // NOI18N
discardOption.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_CTL_Discard")); // NOI18N
discardOption.getAccessibleContext().setAccessibleName(bundle.getString("ACSN_CTL_Discard")); // NOI18N
discardOption.setMnemonic(bundle.getString("CTL_Discard_Mnemonic").charAt(0)); // NOI18N
NotifyDescriptor nd = new NotifyDescriptor(
msg, bundle.getString("LBL_SaveFile_Title"), NotifyDescriptor.YES_NO_CANCEL_OPTION,
NotifyDescriptor.QUESTION_MESSAGE,
new Object[] { saveOption, discardOption, NotifyDescriptor.CANCEL_OPTION }, saveOption
);
Object ret = DialogDisplayer.getDefault().notify(nd);
if (NotifyDescriptor.CANCEL_OPTION.equals(ret) || NotifyDescriptor.CLOSED_OPTION.equals(ret)) {
return 0;
}
if (saveOption.equals(ret)) {
return 1;
} else {
return -1;
}
}
示例7: Macro
import javax.swing.JButton; //导入方法依赖的package包/类
private Macro() {
myName = "%" + name() + "%"; // NOI18N
myButton = new JButton();
myButton.setFocusable(false);
myButton.setToolTipText(getToolTipText());
myButton.setMnemonic(KeyEvent.VK_1 + ordinal());
myButton.setIcon(icon(getClass(), name().toLowerCase()));
}
示例8: ButtonDemo
import javax.swing.JButton; //导入方法依赖的package包/类
public ButtonDemo() {
ImageIcon leftButtonIcon = createImageIcon("images/right.gif");
ImageIcon middleButtonIcon = createImageIcon("images/middle.gif");
ImageIcon rightButtonIcon = createImageIcon("images/left.gif");
b1 = new JButton("Disable middle button", leftButtonIcon);
b1.setVerticalTextPosition(AbstractButton.CENTER);
b1.setHorizontalTextPosition(AbstractButton.LEADING); // aka LEFT, for
// left-to-right
// locales
b1.setMnemonic(KeyEvent.VK_D);
b1.setActionCommand("disable");
b2 = new JButton("Middle button", middleButtonIcon);
b2.setVerticalTextPosition(AbstractButton.BOTTOM);
b2.setHorizontalTextPosition(AbstractButton.CENTER);
b2.setMnemonic(KeyEvent.VK_M);
b3 = new JButton("Enable middle button", rightButtonIcon);
// Use the default text position of CENTER, TRAILING (RIGHT).
b3.setMnemonic(KeyEvent.VK_E);
b3.setActionCommand("enable");
b3.setEnabled(false);
// Listen for actions on buttons 1 and 3.
b1.addActionListener(this);
b3.addActionListener(this);
b1.setToolTipText("Click this button to disable the middle button.");
b2.setToolTipText("This middle button does nothing when you click it.");
b3.setToolTipText("Click this button to enable the middle button.");
// Add Components to this container, using the default FlowLayout.
add(b1);
add(b2);
add(b3);
}
示例9: getCenterPanel
import javax.swing.JButton; //导入方法依赖的package包/类
private JPanel getCenterPanel() {
textArea.setEditable(false);
textArea.setFont(textArea.getFont().deriveFont(textArea.getFont().getSize2D() * 0.9f));
final JScrollPane scrollPane = new JScrollPane(textArea);
// scrollbar vertical à always pour éviter d'avoir la scrollbar horizontal
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
final JPanel scrollPanePanel = new JPanel(DcdUiHelper.createBorderLayout());
scrollPanePanel.setBorder(EMPTY_BORDER);
scrollPanePanel.setOpaque(false);
scrollPanePanel.add(scrollPane, BorderLayout.CENTER);
final JPanel resultsButtonsPanel = new JPanel(DcdUiHelper.createGridLayout(-1, 1, 10, 10));
resultsButtonsPanel.setBorder(EMPTY_BORDER);
resultsButtonsPanel.setOpaque(false);
final JButton cancelButton = createButton("Cancel", "/images/cancel.gif", "cancel");
final JButton copyButton = createButton("Copy", "/images/copy.gif", "copy");
copyButton.setMnemonic(KeyEvent.VK_C);
final JButton clearButton = createButton("Clear", "/images/clear.gif", "clear");
resultsButtonsPanel.add(cancelButton);
resultsButtonsPanel.add(copyButton);
resultsButtonsPanel.add(clearButton);
resultsButtonsPanel.add(progressBar);
// progressBar.setStringPainted(true);
final JPanel resultsButtonsNorthPanel = new JPanel(DcdUiHelper.createBorderLayout());
resultsButtonsNorthPanel.setOpaque(false);
resultsButtonsNorthPanel.add(resultsButtonsPanel, BorderLayout.NORTH);
resultsPanel.setLayout(DcdUiHelper.createBorderLayout());
resultsPanel.setOpaque(false);
resultsPanel.setVisible(false);
resultsPanel.add(scrollPanePanel, BorderLayout.CENTER);
resultsPanel.add(resultsButtonsNorthPanel, BorderLayout.EAST);
return resultsPanel;
}
示例10: initVerticalToolbar
import javax.swing.JButton; //导入方法依赖的package包/类
private void initVerticalToolbar(ActionListener outputListener) {
URL url = getClass().getResource(IMG_PREFIX + "row_add.png"); // NOI18N
insert = new JButton(new ImageIcon(url));
insert.setToolTipText(NbBundle.getMessage(DataViewUI.class, "TOOLTIP_insert")+" (Alt+I)");
insert.setMnemonic('I');
insert.addActionListener(outputListener);
insert.setEnabled(false);
processButton(insert);
editButtons[0] = insert;
url = getClass().getResource(IMG_PREFIX + "row_delete.png"); // NOI18N
deleteRow = new JButton(new ImageIcon(url));
deleteRow.setToolTipText(NbBundle.getMessage(DataViewUI.class, "TOOLTIP_deleterow"));
deleteRow.addActionListener(outputListener);
deleteRow.setEnabled(false);
processButton(deleteRow);
editButtons[1] = deleteRow;
url = getClass().getResource(IMG_PREFIX + "row_commit.png"); // NOI18N
commit = new JButton(new ImageIcon(url));
commit.setToolTipText(NbBundle.getMessage(DataViewUI.class, "TOOLTIP_commit_all"));
commit.addActionListener(outputListener);
commit.setEnabled(false);
processButton(commit);
editButtons[2] = commit;
url = getClass().getResource(IMG_PREFIX + "cancel_edits.png"); // NOI18N
cancel = new JButton(new ImageIcon(url));
cancel.setToolTipText(NbBundle.getMessage(DataViewUI.class, "TOOLTIP_cancel_edits_all"));
cancel.addActionListener(outputListener);
cancel.setEnabled(false);
processButton(cancel);
editButtons[3] = cancel;
//add truncate button
url = getClass().getResource(IMG_PREFIX + "table_truncate.png"); // NOI18N
truncateButton = new JButton(new ImageIcon(url));
truncateButton.setToolTipText(NbBundle.getMessage(DataViewUI.class, "TOOLTIP_truncate_table")+" (Alt+T)");
truncateButton.setMnemonic('T');
truncateButton.addActionListener(outputListener);
truncateButton.setEnabled(false);
processButton(truncateButton);
editButtons[4] = truncateButton;
}
示例11: ButtonHtmlDemo
import javax.swing.JButton; //导入方法依赖的package包/类
public ButtonHtmlDemo() {
ImageIcon leftButtonIcon = createImageIcon("images/right.gif");
ImageIcon middleButtonIcon = createImageIcon("images/middle.gif");
ImageIcon rightButtonIcon = createImageIcon("images/left.gif");
b1 = new JButton("<html><center><b><u>D</u>isable</b><br>" + "<font color=#ffffdd>middle button</font>", leftButtonIcon);
Font font = b1.getFont().deriveFont(Font.PLAIN);
b1.setFont(font);
b1.setVerticalTextPosition(AbstractButton.CENTER);
b1.setHorizontalTextPosition(AbstractButton.LEADING); // aka LEFT, for
// left-to-right
// locales
b1.setMnemonic(KeyEvent.VK_D);
b1.setActionCommand("disable");
b2 = new JButton("middle button", middleButtonIcon);
b2.setFont(font);
b2.setForeground(new Color(0xffffdd));
b2.setVerticalTextPosition(AbstractButton.BOTTOM);
b2.setHorizontalTextPosition(AbstractButton.CENTER);
b2.setMnemonic(KeyEvent.VK_M);
b3 = new JButton("<html><center><b><u>E</u>nable</b><br>" + "<font color=#ffffdd>middle button</font>", rightButtonIcon);
b3.setFont(font);
// Use the default text position of CENTER, TRAILING (RIGHT).
b3.setMnemonic(KeyEvent.VK_E);
b3.setActionCommand("enable");
b3.setEnabled(false);
// Listen for actions on buttons 1 and 3.
b1.addActionListener(this);
b3.addActionListener(this);
b1.setToolTipText("Click this button to disable the middle button.");
b2.setToolTipText("This middle button does nothing when you click it.");
b3.setToolTipText("Click this button to enable the middle button.");
// Add Components to this container, using the default FlowLayout.
add(b1);
add(b2);
add(b3);
}
示例12: getNorthPanel
import javax.swing.JButton; //导入方法依赖的package包/类
private JPanel getNorthPanel() {
final JPanel parametersPanel = getParametersPanel();
final JPanel directoryButtonsPanel = new JPanel(
DcdUiHelper.createGridLayout(-1, 1, 10, 10));
directoryButtonsPanel.setBorder(EMPTY_BORDER);
final JButton addDirectoryButton = createButton("Add a classes directory...",
"/images/add.gif", "addDirectory");
final JButton addJarOrWarButton = createButton("Add a jar or war file...",
"/images/add.gif", "addJarOrWar");
final JButton removeButton = createButton("Remove", "/images/remove.gif", "remove");
directoryButtonsPanel.add(addDirectoryButton);
directoryButtonsPanel.add(addJarOrWarButton);
directoryButtonsPanel.add(removeButton);
directoryButtonsPanel.setOpaque(false);
final JPanel buttonsPanel = new JPanel(DcdUiHelper.createBorderLayout());
buttonsPanel.setOpaque(false);
buttonsPanel.add(directoryButtonsPanel, BorderLayout.NORTH);
final JPanel advancedButtonPanel = new JPanel(DcdUiHelper.createBorderLayout());
advancedButtonPanel.setBorder(EMPTY_BORDER);
advancedButtonPanel.setOpaque(false);
advancedButtonPanel.add(advancedButton, BorderLayout.CENTER);
buttonsPanel.add(advancedButtonPanel, BorderLayout.SOUTH);
final JPanel northPanel = new JPanel(DcdUiHelper.createBorderLayout());
northPanel.setOpaque(false);
final JLabel label = new JLabel(
"<html><b>Add a directory (or list of directories, or jar or war files) containing classes to analyze"
+ "<br/> then choose the type(s) of dead code to detect and click the launch button.");
label.setFont(label.getFont().deriveFont(label.getFont().getSize2D() * 1.2f));
final JPanel runPanel = new JPanel(DcdUiHelper.CENTERED_FLOW_LAYOUT);
runPanel.setBorder(EMPTY_BORDER);
runPanel.setOpaque(false);
final JButton runButton = createButton("Detect dead code", "/images/run.gif", "run");
runButton.setHorizontalAlignment(SwingConstants.CENTER);
runButton.setFont(runButton.getFont().deriveFont(Font.BOLD));
runButton.setMnemonic(KeyEvent.VK_D);
runPanel.add(runButton);
northPanel.add(label, BorderLayout.NORTH);
northPanel.add(parametersPanel, BorderLayout.CENTER);
northPanel.add(buttonsPanel, BorderLayout.EAST);
northPanel.add(runPanel, BorderLayout.SOUTH);
return northPanel;
}
示例13: setupScreen
import javax.swing.JButton; //导入方法依赖的package包/类
private void setupScreen() {
setLayout(new BorderLayout());
setBorder(BorderFactory.createLineBorder(Color.GRAY));
// add main panel to XSheet
mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
add(mainPanel, BorderLayout.CENTER);
// add south panel to XSheet
southPanel = new JPanel();
add(southPanel, BorderLayout.SOUTH);
// create the refresh button
refreshButton = new JButton(Messages.MBEANS_TAB_REFRESH_ATTRIBUTES_BUTTON);
refreshButton.setMnemonic(Resources.getMnemonicInt(Messages.MBEANS_TAB_REFRESH_ATTRIBUTES_BUTTON));
refreshButton.setToolTipText(Messages.MBEANS_TAB_REFRESH_ATTRIBUTES_BUTTON_TOOLTIP);
refreshButton.addActionListener(this);
// create the clear button
clearButton = new JButton(Messages.MBEANS_TAB_CLEAR_NOTIFICATIONS_BUTTON);
clearButton.setMnemonic(Resources.getMnemonicInt(Messages.MBEANS_TAB_CLEAR_NOTIFICATIONS_BUTTON));
clearButton.setToolTipText(Messages.MBEANS_TAB_CLEAR_NOTIFICATIONS_BUTTON_TOOLTIP);
clearButton.addActionListener(this);
// create the subscribe button
subscribeButton = new JButton(Messages.MBEANS_TAB_SUBSCRIBE_NOTIFICATIONS_BUTTON);
subscribeButton.setMnemonic(Resources.getMnemonicInt(Messages.MBEANS_TAB_SUBSCRIBE_NOTIFICATIONS_BUTTON));
subscribeButton.setToolTipText(Messages.MBEANS_TAB_SUBSCRIBE_NOTIFICATIONS_BUTTON_TOOLTIP);
subscribeButton.addActionListener(this);
// create the unsubscribe button
unsubscribeButton = new JButton(Messages.MBEANS_TAB_UNSUBSCRIBE_NOTIFICATIONS_BUTTON);
unsubscribeButton.setMnemonic(Resources.getMnemonicInt(Messages.MBEANS_TAB_UNSUBSCRIBE_NOTIFICATIONS_BUTTON));
unsubscribeButton.setToolTipText(Messages.MBEANS_TAB_UNSUBSCRIBE_NOTIFICATIONS_BUTTON_TOOLTIP);
unsubscribeButton.addActionListener(this);
// create XMBeanAttributes container
mbeanAttributes = new XMBeanAttributes(mbeansTab);
// create XMBeanOperations container
mbeanOperations = new XMBeanOperations(mbeansTab);
mbeanOperations.addOperationsListener(this);
// create XMBeanNotifications container
mbeanNotifications = new XMBeanNotifications();
mbeanNotifications.addNotificationsListener(this);
// create XMBeanInfo container
mbeanInfo = new XMBeanInfo();
}
示例14: addButton
import javax.swing.JButton; //导入方法依赖的package包/类
private void addButton(JPanel buttons, String rkey, int mnemonic, ActionListener action) {
JButton but = new JButton(getResourceString(rkey));
but.setMnemonic(mnemonic);
buttons.add(but);
but.addActionListener(action);
}