use of com.mucommander.commons.util.ui.helper.MnemonicHelper in project mucommander by mucommander.
the class ButtonChoicePanel method updateMnemonics.
/**
* Updates the buttons mnemonics. This method should be called when at least one of the button's label has changed.
*/
public void updateMnemonics() {
MnemonicHelper mnemonicHelper = new MnemonicHelper();
char mnemonic;
for (JButton button : buttons) {
mnemonic = mnemonicHelper.getMnemonic(button);
if (mnemonic != 0)
button.setMnemonic(mnemonic);
}
}
use of com.mucommander.commons.util.ui.helper.MnemonicHelper in project mucommander by mucommander.
the class DialogToolkit method createButtonPanel.
/**
* Creates a button panel using the given buttons, and register the given listener for button actions.
* Buttons are disposed horizontally, aligned to the right.
*/
public static JPanel createButtonPanel(List<JButton> buttons, JRootPane rootPane, ActionListener actionListener) {
JPanel panel = new ButtonChoicePanel(buttons, 0, rootPane);
MnemonicHelper mnemonicHelper = new MnemonicHelper();
for (JButton button : buttons) {
button.setMnemonic(mnemonicHelper.getMnemonic(button.getText()));
button.addActionListener(actionListener);
panel.add(button);
}
return panel;
}
use of com.mucommander.commons.util.ui.helper.MnemonicHelper in project mucommander by mucommander.
the class DialogToolkit method createButtonPanel.
/**
* Creates a button panel using the given buttons, and register the given listener for button actions.
* Buttons are disposed horizontally, aligned to the right.
*/
public static JPanel createButtonPanel(JButton[] buttons, JRootPane rootPane, ActionListener actionListener) {
JPanel panel = new ButtonChoicePanel(buttons, 0, rootPane);
MnemonicHelper mnemonicHelper = new MnemonicHelper();
for (JButton button : buttons) {
button.setMnemonic(mnemonicHelper.getMnemonic(button.getText()));
button.addActionListener(actionListener);
panel.add(button);
}
return panel;
}
use of com.mucommander.commons.util.ui.helper.MnemonicHelper in project mucommander by mucommander.
the class BonjourMenu method menuSelected.
// ///////////////////////////////
// MenuListener implementation //
// ///////////////////////////////
public void menuSelected(MenuEvent menuEvent) {
// Remove previous menu items (if any)
removeAll();
if (BonjourDirectory.isActive()) {
BonjourService[] services = BonjourDirectory.getServices();
int nbServices = services.length;
if (nbServices > 0) {
// Add a menu item for each Bonjour service.
// When clicked, the corresponding URL will opened in the active table.
JMenuItem menuItem;
MnemonicHelper mnemonicHelper = new MnemonicHelper();
for (int i = 0; i < nbServices; i++) {
menuItem = new JMenuItem(getMenuItemAction(services[i]));
menuItem.setMnemonic(mnemonicHelper.getMnemonic(menuItem.getText()));
add(menuItem);
}
} else {
// Inform that no service have been discovered
add(new JMenuItem(Translator.get("bonjour.no_service_discovered"))).setEnabled(false);
}
} else {
// Inform that Bonjour support has been disabled
add(new JMenuItem(Translator.get("bonjour.bonjour_disabled"))).setEnabled(false);
}
}
use of com.mucommander.commons.util.ui.helper.MnemonicHelper in project mucommander by mucommander.
the class BinaryEditor method initMenuBars.
private void initMenuBars() {
MnemonicHelper menuItemMnemonicHelper = new MnemonicHelper();
fileMenu = new JMenu(Translator.get("binary_editor.file"));
int metaMask = getMetaMask();
saveMenuItem = MenuToolkit.addMenuItem(fileMenu, Translator.get("binary_editor.save"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_S, metaMask), e -> saveFile());
saveAsMenuItem = MenuToolkit.addMenuItem(fileMenu, Translator.get("binary_editor.save_as"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.SHIFT_DOWN_MASK | metaMask), e -> saveAsFile());
cutMenuItem = MenuToolkit.createMenuItem(Translator.get("binary_editor.cut"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_X, metaMask), e -> binaryComponent.getCodeArea().cut());
editMenu.add(cutMenuItem, copyMenuItemPosition);
pasteMenuItem = MenuToolkit.createMenuItem(Translator.get("binary_editor.paste"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_V, metaMask), e -> binaryComponent.getCodeArea().paste());
deleteMenuItem = MenuToolkit.createMenuItem(Translator.get("binary_editor.delete"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), e -> binaryComponent.getCodeArea().delete());
editMenu.add(pasteMenuItem, copyMenuItemPosition + 2);
editMenu.add(deleteMenuItem, copyMenuItemPosition + 3);
JPopupMenu popupMenu = new JPopupMenu();
cutPopupMenuItem = MenuToolkit.createMenuItem(Translator.get("binary_editor.cut"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_X, metaMask), e -> binaryComponent.getCodeArea().cut());
popupMenu.add(cutPopupMenuItem);
copyPopupMenuItem = MenuToolkit.createMenuItem(Translator.get("binary_viewer.copy"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_C, getMetaMask()), e -> binaryComponent.getCodeArea().copy());
popupMenu.add(copyPopupMenuItem);
pastePopupMenuItem = MenuToolkit.createMenuItem(Translator.get("binary_editor.paste"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_V, metaMask), e -> binaryComponent.getCodeArea().paste());
popupMenu.add(pastePopupMenuItem);
deletePopupMenuItem = MenuToolkit.createMenuItem(Translator.get("binary_editor.delete"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), e -> binaryComponent.getCodeArea().delete());
popupMenu.add(deletePopupMenuItem);
popupMenu.add(MenuToolkit.createMenuItem(Translator.get("binary_viewer.select_all"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_A, getMetaMask()), e -> binaryComponent.getCodeArea().selectAll()));
binaryComponent.getCodeArea().setComponentPopupMenu(popupMenu);
}
Aggregations