下面列出了怎么用javax.swing.KeyStroke的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Creates a new {@code FreeColAction}.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param id The object identifier for this action.
*/
protected FreeColAction(FreeColClient freeColClient, String id) {
super(Messages.getName(id));
this.freeColClient = freeColClient;
putValue(ACTION_ID, id);
String shortDescription = Messages.getDescription(id);
if (!shortDescription.equals(Messages.descriptionKey(id))) {
putValue(SHORT_DESCRIPTION, shortDescription);
}
String acceleratorKey = id + ".accelerator";
String accelerator = Messages.message(acceleratorKey);
if (!accelerator.equals(acceleratorKey)) {
setAccelerator(KeyStroke.getKeyStroke(accelerator));
}
}
@Override
protected JButton makeCancelButton() {
ResourceAction cancelAction = new ResourceAction("cancel") {
private static final long serialVersionUID = -8887199234055845095L;
@Override
public void loggedActionPerformed(ActionEvent e) {
returnOption = CANCEL_OPTION;
cancel();
}
};
JButton cancelButton = new JButton(cancelAction);
getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false), "CANCEL");
getRootPane().getActionMap().put("CANCEL", cancelAction);
return cancelButton;
}
/** Same method as above, but works just with plain actions.
*/
private static String findKey(Action action) {
if (action == null) {
return null;
}
KeyStroke accelerator = (KeyStroke) action.getValue(Action.ACCELERATOR_KEY);
if (accelerator == null) {
return null;
}
int modifiers = accelerator.getModifiers();
String acceleratorText = ""; // NOI18N
if (modifiers > 0) {
acceleratorText = KeyEvent.getKeyModifiersText(modifiers);
acceleratorText += "+"; // NOI18N
} else if (accelerator.getKeyCode() == KeyEvent.VK_UNDEFINED) {
return ""; // NOI18N
}
acceleratorText += KeyEvent.getKeyText(accelerator.getKeyCode());
return acceleratorText;
}
public void testInstantRefactor() {
startTest();
createSampleProject("NB Project Generators", testRefactor.TEST_BASE_NAME + testRefactor.name_iterator);
openFile("generators|NetBeansModule.groovy", testRefactor.TEST_BASE_NAME + testRefactor.name_iterator);
waitScanFinished();
EditorOperator ep = new EditorOperator("NetBeansModule.groovy");
ep.setCaretPosition(7, 7);
evt.waitNoEvent(2000);
new org.netbeans.jellytools.actions.Action(null, null, KeyStroke.getKeyStroke(KeyEvent.VK_R, 2)).performShortcut(ep);
type(ep, "packg");
ep.pressKey(KeyEvent.VK_ENTER);
assertTrue("file not refactored - contains old value: \n" + ep.getText(), !ep.getText().contains("pkgs"));
assertTrue("file not refactored - does not contain new value: \n" + ep.getText(), ep.getText().contains("packg"));
testRefactor.name_iterator++;
endTest();
}
Popup() {
super(" "); // NOI18N
// See GenericToolbar.addImpl()
putClientProperty("MetalListener", new Object()); // NOI18N
setModel(new DefaultButtonModel() {
public boolean isRollover() {
return super.isRollover() || pushed;
}
});
setHorizontalAlignment(LEADING);
setDefaultCapable(false);
getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, false), NO_ACTION);
getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, true), NO_ACTION);
}
/**
* Convert an array of {@link KeyStroke key stroke} to a string composed of
* human-readable names of these key strokes, delimited by {@code delim}.
*/
public static String getKeyStrokesAsText(
@NullAllowed KeyStroke[] keyStrokes, @NonNull String delim) {
if (keyStrokes == null) {
return ""; //NOI18N
}
if (keyStrokes.length == 0) {
return ""; //NOI18N
}
StringBuilder sb = new StringBuilder(getKeyStrokeAsText(keyStrokes[0]));
int i, k = keyStrokes.length;
for (i = 1; i < k; i++) {
sb.append(delim).append(getKeyStrokeAsText(keyStrokes[i]));
}
return new String(sb);
}
/**
* Return JTree's input map.
*/
protected InputMap getInputMap(int condition)
{
InputMap map = super.getInputMap(condition);
if (condition == JComponent.WHEN_FOCUSED && map != null)
{
map.put(KeyStroke.getKeyStroke("control S"), "save");
map.put(KeyStroke.getKeyStroke("control shift S"), "saveAs");
map.put(KeyStroke.getKeyStroke("control N"), "new");
map.put(KeyStroke.getKeyStroke("control O"), "open");
map.put(KeyStroke.getKeyStroke("control Z"), "undo");
map.put(KeyStroke.getKeyStroke("control Y"), "redo");
map
.put(KeyStroke.getKeyStroke("control shift V"),
"selectVertices");
map.put(KeyStroke.getKeyStroke("control shift E"), "selectEdges");
}
return map;
}
/**
* Manage low level key strokes ESCAPE : Close the window
*
* @return
*/
protected JRootPane createRootPane() {
JRootPane rootPane = new JRootPane();
KeyStroke strokeEscape = KeyStroke.getKeyStroke("ESCAPE");
@SuppressWarnings("serial")
Action actionListener = new AbstractAction() {
public void actionPerformed(ActionEvent actionEvent) {
setVisible(false);
}
};
InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
inputMap.put(strokeEscape, "ESCAPE");
rootPane.getActionMap().put("ESCAPE", actionListener);
return rootPane;
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
setLayout(new BorderLayout());
this.setSize(581, 39);
this.add(getJPanel(), java.awt.BorderLayout.WEST);
setFocusable(true);
final AbstractAction aa = new AbstractAction() {
/**
*
*/
private static final long serialVersionUID = 1L;
public void actionPerformed(ActionEvent e) {
findNext(jTextField.getText(), jCheckBox.isSelected());
}
};
this.getInputMap().put(KeyStroke.getKeyStroke("F3"), "FindNext");
this.getActionMap().put("FindNext", aa);
getJTextField().getInputMap().put(KeyStroke.getKeyStroke("F3"),
"FindNext");
getJTextField().getActionMap().put("FindNext", aa);
}
final MButton createRefreshButton() {
final MButton refreshButton = new MButton(getString("Actualiser"),
ImageIconCache.getImageIcon("action_refresh.png"));
refreshButton.setToolTipText(getString("Rafraichir") + " (F5)");
refreshButton.setActionCommand("refresh");
refreshButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(KeyStroke.getKeyStroke("F5"), "doRefresh");
refreshButton.getActionMap().put("doRefresh", new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent e) {
refreshButton.doClick();
}
});
return refreshButton;
}
/**
* Creates new form CompareResultImages
*/
public CompareResultImages() {
initComponents();
toReviewList.setModel(new DefaultListModel());
fillList();
setSize(800, 600);
setExtendedState(getExtendedState() | MAXIMIZED_BOTH);
actualImage.setStretch(false);
referenceImage.setStretch(false);
acceptAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control D"));
InputMap keyMap = new ComponentInputMap(acceptButton);
keyMap.put(KeyStroke.getKeyStroke("control D"), "accept");
ActionMap actionMap = new ActionMapUIResource();
actionMap.put("accept", acceptAction);
SwingUtilities.replaceUIActionMap(acceptButton, actionMap);
SwingUtilities.replaceUIInputMap(acceptButton, JComponent.WHEN_IN_FOCUSED_WINDOW, keyMap);
}
protected void buildBelowDetailsPanel() {
Insets small = new Insets( 1, 1, 1, 1 );
lblChanges = new JLabel( "Changes: " );
btnSaveChanges = new JButton( "Save" );
// btnSaveChanges.setMnemonic( java.awt.event.KeyEvent.VK_ENTER );
btnSaveChanges.getInputMap( btnSaveChanges.WHEN_IN_FOCUSED_WINDOW )
.put( KeyStroke.getKeyStroke( CPSGlobalSettings.getModifierKey() + " ENTER" ), "save" );
btnSaveChanges.getActionMap().put( "save",
new AbstractAction() {
public void actionPerformed(ActionEvent e) {
btnSaveChanges.doClick();
}
});
btnDiscardChanges = new JButton( "Discard" );
btnSaveChanges.addActionListener( this );
btnDiscardChanges.addActionListener( this );
btnSaveChanges.setMargin( small );
btnDiscardChanges.setMargin( small );
initBelowDetailsPanel();
jplBelowDetails.add( lblStatus );
jplBelowDetails.add( Box.createHorizontalGlue() );
jplBelowDetails.add( lblChanges );
jplBelowDetails.add( btnSaveChanges );
jplBelowDetails.add( btnDiscardChanges );
}
public static void removeKeyBinding(JComponent component, String key)
{
int condition = JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT;
InputMap inputMap = component.getInputMap(condition);
// According to the docs, null should remove the action, but it does
// not seem to work with Sun Java 1.4.2, new Object() works
inputMap.put(KeyStroke.getKeyStroke(key), new Object());
}
private void initActions() {
InputMap inputMap = getInputMap( WHEN_FOCUSED );
inputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_LEFT, 0, false ), "collapse" ); //NOI18N
inputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_RIGHT, 0, false ), "expand" ); //NOI18N
ActionMap actionMap = getActionMap();
actionMap.put( "collapse", new ExpandAction( false ) ); //NOI18N
actionMap.put( "expand", new ExpandAction( true ) ); //NOI18N
}
private void setupProcTable() {
DefaultTableModel procTableModel = new DefaultTableModel();
procTableModel.addColumn("Character(s)");
procTableModel.addColumn("Pronunciation");
tblProcs.setModel(procTableModel); // TODO: find way to make tblProcs display RTL order when appropriate Maybe something on my custom cell editor
boolean useConFont = !core.getPropertiesManager().isOverrideRegexFont();
TableColumn column = tblProcs.getColumnModel().getColumn(0);
column.setCellEditor(new PCellEditor(useConFont, core));
column.setCellRenderer(new PCellRenderer(useConFont, core));
column = tblProcs.getColumnModel().getColumn(1);
column.setCellEditor(new PCellEditor(false, core));
column.setCellRenderer(new PCellRenderer(false, core));
// disable tab/arrow selection
InputMap procInput = tblProcs.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
procInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "none");
procInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_DOWN_MASK), "none");
procInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), "none");
procInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.SHIFT_DOWN_MASK), "none");
procInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), "none");
procInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.SHIFT_DOWN_MASK), "none");
procInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "none");
procInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.SHIFT_DOWN_MASK), "none");
procInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "none");
procInput.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.SHIFT_DOWN_MASK), "none");
}
protected JRootPane createRootPane() {
ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
dispose();
}
};
JRootPane rootPane = new JRootPane();
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
return rootPane;
}
public JTextComponentMenu(JTextComponent parent, UndoManager undoManager) {
super();
this.parent = parent;
this.undoManager = undoManager;
int keyMask =Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
undoAction = new UndoAction(undoManager);
undoAction.putValue(Action.NAME, MessageBundle.get("swing.action.undo"));
undoAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_Z, keyMask));
add(undoAction);
addSeparator();
cutAction = new DefaultEditorKit.CutAction();
cutAction.putValue(Action.NAME, MessageBundle.get("swing.action.cut"));
cutAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_X, keyMask));
add(cutAction);
copyAction = new DefaultEditorKit.CopyAction();
copyAction.putValue(Action.NAME, MessageBundle.get("swing.action.copy"));
copyAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C, keyMask));
add(copyAction);
Action pasteAction = new DefaultEditorKit.PasteAction();
pasteAction.putValue(Action.NAME, MessageBundle.get("swing.action.paste"));
pasteAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_V, keyMask));
add(pasteAction);
deleteAction = new DeleteAction(MessageBundle.get("swing.action.delete"));
add(deleteAction);
addSeparator();
Action selectAllAction = new SelectAllAction(MessageBundle.get("swing.action.selectall"));
selectAllAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_A, keyMask));
add(selectAllAction);
}
public JMenu getEditMenu() {
final JMenu menu = new JMenu("Edit");
menu.setMnemonic('E');
menu.add(menuItem("Cut", 'X', KeyStroke.getKeyStroke(KeyEvent.VK_X, CMD_CTRL_KEY_MASK), new DefaultEditorKit.CutAction()));
menu.add(menuItem("Copy", 'C', KeyStroke.getKeyStroke(KeyEvent.VK_C, CMD_CTRL_KEY_MASK), new DefaultEditorKit.CopyAction()));
menu.add(menuItem("Paste", 'V', KeyStroke.getKeyStroke(KeyEvent.VK_V, CMD_CTRL_KEY_MASK), new DefaultEditorKit.PasteAction()));
return menu;
}
RootDirectoryAction ()
// ---------------------------------------------------------------------------------//
{
super ("Set HOME folder...", "Defines root folder where the disk images are kept",
"/com/bytezone/diskbrowser/icons/");
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt H"));
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_H);
setIcon (Action.SMALL_ICON, "folder_explore_16.png");
setIcon (Action.LARGE_ICON_KEY, "folder_explore_32.png");
}
public RefreshTreeAction (CatalogPanel owner)
// ---------------------------------------------------------------------------------//
{
super ("Refresh current tree", "Makes newly added/modified disks available",
"/com/bytezone/diskbrowser/icons/");
// putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt R"));
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke (KeyEvent.VK_F5, 0));
// putValue (Action.MNEMONIC_KEY, KeyEvent.VK_R);
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_F5);
this.owner = owner;
setIcon (Action.SMALL_ICON, "arrow_refresh.png");
setIcon (Action.LARGE_ICON_KEY, "arrow_refresh_32.png");
}
/**
* Creates a new instance which acts on the specified component.
*
* @param target The target of the action. Specify null for the currently
* focused component.
*/
public DuplicateAction(JComponent target) {
super(target);
putValue(NAME, BUNDLE.getString("duplicateAction.name"));
putValue(SHORT_DESCRIPTION, BUNDLE.getString("duplicateAction.shortDescription"));
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("ctrl D"));
ImageIcon icon = ImageDirectory.getImageIcon("/menu/edit-copy-3.png");
putValue(SMALL_ICON, icon);
putValue(LARGE_ICON_KEY, icon);
}
private void init() {
table = new Table<AttributeDefinition>(model);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.getTableHeader().setVisible(true);
table.getColumnModel().getColumn(4).setCellEditor(new CapabilityTableCellEditor() {
@Override
protected Object renderValue(Object value) {
AttributeDefinition ad = (AttributeDefinition) value;
String name = getAttributeName(ad);
return getValue(name);
}
});
table
.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK), "copy");
table.getActionMap().put("copy", copy);
table.getActionMap().put("logit", Actions.builder().withAction((event) -> logger.warn("LOGIT {}", event)).build());
table.addMouseListener(new RightClickMouseAdapter());
setLayout(new BorderLayout());
JPanel tablePane = new JPanel();
tablePane.setLayout(new BorderLayout());
tablePane.add(table.getTableHeader(), BorderLayout.NORTH);
tablePane.add(table, BorderLayout.CENTER);
add(tablePane, BorderLayout.CENTER);
setCapabilityDefinition(definition);
}
/**
* Creates nice textual representation of KeyStroke.
* Modifiers and an actual key label are concated by plus signs
* @param the KeyStroke to get description of
* @return String describing the KeyStroke
*/
public static String keyStrokeToString( KeyStroke stroke ) {
String modifText = KeyEvent.getKeyModifiersText( stroke.getModifiers() );
String keyText = (stroke.getKeyCode() == KeyEvent.VK_UNDEFINED) ?
String.valueOf(stroke.getKeyChar()) : getKeyText(stroke.getKeyCode());
if( modifText.length() > 0 ) return modifText + '+' + keyText;
else return keyText;
}
public KeyStroke registerAction(String actionKey, Action action, ActionMap actionMap, InputMap inputMap) {
if (!FILTER_ACTION_KEY.equals(actionKey)) return null;
KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_G, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
actionMap.put(actionKey, action);
inputMap.put(ks, actionKey);
return ks;
}
public void keyPressed(KeyEvent e) {
if ((e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU)
|| ((e.getKeyCode() == KeyEvent.VK_F10) && (e.getModifiers() == InputEvent.SHIFT_MASK))) {
int selectedRow = instancesListTable.getSelectedRow();
if (selectedRow != -1) {
Rectangle rowBounds = instancesListTable.getCellRect(selectedRow, 0, true);
showTablePopup(instancesListTable, rowBounds.x + (rowBounds.width / 2), rowBounds.y + (rowBounds.height / 2));
}
} else if (KeyStroke.getAWTKeyStroke(e.getKeyCode(), e.getModifiers()).equals(COPY_ID_KEYSTROKE)) {
copyIdToClipboard();
}
}
/**
* Construct a new JMenuItem then add it to an existing JMenu.
*
* @param parent - the JMenu to add this JMenuItem into (or null if you don't
* want to add it to any JMenu yet)
* @param label - the text to show on the menu
* @param attrs - a list of attributes to apply onto the new JMenuItem
* <p>
* If one positive number a is supplied, we call setMnemonic(a)
* <p>
* If two positive numbers a and b are supplied, and a!=VK_ALT, and
* a!=VK_SHIFT, we call setMnemoic(a) and setAccelerator(b)
* <p>
* If two positive numbers a and b are supplied, and a==VK_ALT or
* a==VK_SHIFT, we call setAccelerator(a | b)
* <p>
* If an ActionListener is supplied, we call addActionListener(x)
* <p>
* If an Boolean x is supplied, we call setEnabled(x)
* <p>
* If an Icon x is supplied, we call setIcon(x)
*/
public static JMenuItem menuItem(JMenu parent, String label, Object... attrs) {
JMenuItem m = new JMenuItem(label, null);
int accelMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
boolean hasMnemonic = false;
for (Object x : attrs) {
if (x instanceof Character || x instanceof Integer) {
int k = (x instanceof Character) ? ((int) ((Character) x)) : ((Integer) x).intValue();
if (k < 0)
continue;
if (k == KeyEvent.VK_ALT) {
hasMnemonic = true;
accelMask = accelMask | InputEvent.ALT_MASK;
continue;
}
if (k == KeyEvent.VK_SHIFT) {
hasMnemonic = true;
accelMask = accelMask | InputEvent.SHIFT_MASK;
continue;
}
if (!hasMnemonic) {
m.setMnemonic(k);
hasMnemonic = true;
} else
m.setAccelerator(KeyStroke.getKeyStroke(k, accelMask));
}
if (x instanceof ActionListener)
m.addActionListener((ActionListener) x);
if (x instanceof Icon)
m.setIcon((Icon) x);
if (x instanceof Boolean)
m.setEnabled((Boolean) x);
}
if (parent != null)
parent.add(m);
return m;
}
public @Override void keyPressed(KeyEvent e){
if (e != null && popup != null && popup.isShowing()) {
// get popup's registered keyboard actions
ActionMap am = popup.getActionMap();
InputMap im = popup.getInputMap();
// check whether popup registers keystroke
KeyStroke ks = KeyStroke.getKeyStrokeForEvent(e);
Object obj = im.get(ks);
LOG.log(Level.FINE, "Keystroke for event {0}: {1}; action-map-key={2}", new Object [] { e, ks, obj }); //NOI18N
if (shouldPopupReceiveForwardedKeyboardAction(obj)) {
// if yes, gets the popup's action for this keystroke, perform it
// and consume key event
Action action = am.get(obj);
LOG.log(Level.FINE, "Popup component''s action: {0}, {1}", new Object [] { action, action != null ? action.getValue(Action.NAME) : null }); //NOI18N
/* Make sure to use the popup as the source of the action, since the popup is
also providing the event. Not doing this, and instead invoking actionPerformed
with a null ActionEvent, was one part of the problem seen in NETBEANS-403. */
if (SwingUtilities.notifyAction(action, ks, e, popup, e.getModifiers())) {
e.consume();
return;
}
}
if (e.getKeyCode() != KeyEvent.VK_CONTROL &&
e.getKeyCode() != KeyEvent.VK_SHIFT &&
e.getKeyCode() != KeyEvent.VK_ALT &&
e.getKeyCode() != KeyEvent.VK_ALT_GRAPH &&
e.getKeyCode() != KeyEvent.VK_META
) {
// hide tooltip if any was shown
Utilities.getEditorUI(textComponent).getToolTipSupport().setToolTipVisible(false);
}
}
}
private static String getExpandKeyStrokeText(KeyStroke keyStroke) {
String expandKeyStrokeText;
if (keyStroke.equals(KeyStroke.getKeyStroke(' '))) { //NOI18N
expandKeyStrokeText = "SPACE"; // NOI18N
} else if (keyStroke.equals(KeyStroke.getKeyStroke(new Character(' '), InputEvent.SHIFT_MASK))) { //NOI18N
expandKeyStrokeText = "Shift-SPACE"; // NOI18N
} else if (keyStroke.equals(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0))) {
expandKeyStrokeText = "TAB"; // NOI18N
} else if (keyStroke.equals(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0))) {
expandKeyStrokeText = "ENTER"; // NOI18N
} else {
expandKeyStrokeText = keyStroke.toString();
}
return expandKeyStrokeText;
}
public JPQLEditorPopupMouseAdapter() {
super();
popupMenu = new JPopupMenu();
ActionListener actionListener = new PopupActionListener();
runJPQLMenuItem = popupMenu.add(RUN_JPQL_COMMAND);
runJPQLMenuItem.setMnemonic('Q');
runJPQLMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.ALT_MASK | InputEvent.SHIFT_MASK, false));
runJPQLMenuItem.addActionListener(actionListener);
popupMenu.addSeparator();
cutMenuItem = popupMenu.add(CUT_COMMAND);
cutMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK, true));
cutMenuItem.setMnemonic('t');
cutMenuItem.addActionListener(actionListener);
copyMenuItem = popupMenu.add(COPY_COMMAND);
copyMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK, true));
copyMenuItem.setMnemonic('y');
copyMenuItem.addActionListener(actionListener);
pasteMenuItem = popupMenu.add(PASTE_COMMAND);
pasteMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK, true));
pasteMenuItem.setMnemonic('P');
pasteMenuItem.addActionListener(actionListener);
popupMenu.addSeparator();
selectAllMenuItem = popupMenu.add(SELECT_ALL_COMMAND);
selectAllMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK, true));
selectAllMenuItem.setMnemonic('A');
selectAllMenuItem.addActionListener(actionListener);
}
/**
* Construct action.
*/
public ExamineCsrAction()
{
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(
RB.getString("FPortecle.ExamineCsrAction.accelerator").charAt(0), InputEvent.CTRL_MASK));
putValue(LONG_DESCRIPTION, RB.getString("FPortecle.ExamineCsrAction.statusbar"));
putValue(MNEMONIC_KEY, Integer.valueOf(RB.getString("FPortecle.ExamineCsrAction.mnemonic").charAt(0)));
putValue(NAME, RB.getString("FPortecle.ExamineCsrAction.text"));
putValue(SHORT_DESCRIPTION, RB.getString("FPortecle.ExamineCsrAction.tooltip"));
putValue(SMALL_ICON, new ImageIcon(getResImage("FPortecle.ExamineCsrAction.image")));
setEnabled(true);
}