本文整理汇总了Java中java.awt.event.ActionEvent.getModifiers方法的典型用法代码示例。如果您正苦于以下问题:Java ActionEvent.getModifiers方法的具体用法?Java ActionEvent.getModifiers怎么用?Java ActionEvent.getModifiers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.event.ActionEvent
的用法示例。
在下文中一共展示了ActionEvent.getModifiers方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import java.awt.event.ActionEvent; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent evt) {
int increment = 1;
if((evt.getModifiers() & ActionEvent.SHIFT_MASK) > 0) {
// CTRL pressed -> use tokens for advancing
increment = SHIFT_INCREMENT;
if((evt.getModifiers() & ActionEvent.CTRL_MASK) > 0) {
increment = CTRL_SHIFT_INCREMENT;
}
}
long newValue = ann.getStartNode().getOffset().longValue() - increment;
if(newValue < 0) newValue = 0;
try {
moveAnnotation(set, ann, new Long(newValue), ann.getEndNode()
.getOffset());
} catch(InvalidOffsetException ioe) {
throw new GateRuntimeException(ioe);
}
}
示例2: isValidDefaultTypedAction
import java.awt.event.ActionEvent; //导入方法依赖的package包/类
/**
* Checks that the action will result in an insertion into document.
* Returns true for readonly docs as well.
*
* @param evt action event
* @return true, if the action event will result in insertion; readonly doc status is not
* checked.
*/
static boolean isValidDefaultTypedAction(ActionEvent evt) {
// Check whether the modifiers are OK
int mod = evt.getModifiers();
boolean ctrl = ((mod & ActionEvent.CTRL_MASK) != 0);
boolean alt = org.openide.util.Utilities.isMac() ? ((mod & ActionEvent.META_MASK) != 0) :
((mod & ActionEvent.ALT_MASK) != 0);
return !(alt || ctrl);
}
示例3: actionPerformed
import java.awt.event.ActionEvent; //导入方法依赖的package包/类
public @Override void actionPerformed(ActionEvent evt, JTextComponent target) {
String cmd = evt.getActionCommand();
int mod = evt.getModifiers();
// Dirty fix for Completion shortcut on Unix !!!
if (cmd != null && cmd.equals(" ") && (mod == ActionEvent.CTRL_MASK)) { // NOI18N
// Ctrl + SPACE
} else {
Caret caret = target.getCaret();
if (caret instanceof ExtCaret) {
((ExtCaret)caret).requestMatchBraceUpdateSync(); // synced bracket update
}
super.actionPerformed(evt, target);
}
if ((target != null) && (evt != null)) {
if ((cmd != null) && (cmd.length() == 1)) {
// Check whether char that should reindent the line was inserted
checkIndentHotChars(target, cmd);
// Check the completion
checkCompletion(target, cmd);
}
}
}
示例4: actionPerformed
import java.awt.event.ActionEvent; //导入方法依赖的package包/类
@Override
public void actionPerformed( ActionEvent e ) {
nd.setValue(option);
if (buttonListener != null) {
// #34485: some listeners expect that the action source is the option, not the button
ActionEvent e2 = new ActionEvent(
option, e.getID(), e.getActionCommand(), e.getWhen(), e.getModifiers()
);
buttonListener.actionPerformed(e2);
}
if ((closingOptions == null) || Arrays.asList(closingOptions).contains(option)) {
haveFinalValue = true;
setVisible(false);
}
}
示例5: actionPerformed
import java.awt.event.ActionEvent; //导入方法依赖的package包/类
/**
* The operation to perform when this action is triggered.
*
* @param e the action event
*/
public void actionPerformed(ActionEvent e) {
JTextComponent target = getTextComponent(e);
if ((target != null) && (e != null)) {
if ((! target.isEditable()) || (! target.isEnabled())) {
return;
}
String content = e.getActionCommand();
int mod = e.getModifiers();
if ((content != null) && (content.length() > 0)) {
boolean isPrintableMask = true;
Toolkit tk = Toolkit.getDefaultToolkit();
if (tk instanceof SunToolkit) {
isPrintableMask = ((SunToolkit)tk).isPrintableCharacterModifiersMask(mod);
}
if (isPrintableMask) {
char c = content.charAt(0);
if ((c >= 0x20) && (c != 0x7F)) {
target.replaceSelection(content);
}
}
}
}
}
示例6: isValidDefaultTypedAction
import java.awt.event.ActionEvent; //导入方法依赖的package包/类
/**
* Copied from BaseKit
*/
static boolean isValidDefaultTypedAction(ActionEvent evt) {
// Check whether the modifiers are OK
int mod = evt.getModifiers();
boolean ctrl = ((mod & ActionEvent.CTRL_MASK) != 0);
boolean alt = org.openide.util.Utilities.isMac() ? ((mod & ActionEvent.META_MASK) != 0) :
((mod & ActionEvent.ALT_MASK) != 0);
return !(alt || ctrl);
}
示例7: actionPerformed
import java.awt.event.ActionEvent; //导入方法依赖的package包/类
/**
* This method is final so that you cannot override it and mess up the
* macro-recording part of it. The actual meat of the action is in
* <code>actionPerformedImpl</code>.
*
* @param e The action being performed.
* @see #actionPerformedImpl
*/
@Override
public final void actionPerformed(ActionEvent e) {
JTextComponent textComponent = getTextComponent(e);
if (textComponent instanceof RTextArea) {
RTextArea textArea = (RTextArea)textComponent;
//System.err.println("Recordable action: " + getMacroID());
if (RTextArea.isRecordingMacro() && isRecordable()) {
int mod = e.getModifiers();
// We ignore keypresses involving ctrl/alt/meta if they are
// "default" keypresses - i.e., they aren't some special
// action like paste (e.g., paste would return Ctrl+V, but
// its action would be "paste-action").
String macroID = getMacroID();
//System.err.println(macroID);
//System.err.println("... " + (mod&ActionEvent.ALT_MASK));
//System.err.println("... " + (mod&ActionEvent.CTRL_MASK));
//System.err.println("... " + (mod&ActionEvent.META_MASK));
if (!DefaultEditorKit.defaultKeyTypedAction.equals(macroID) || (
(mod&ActionEvent.ALT_MASK)==0 &&
(mod&ActionEvent.CTRL_MASK)==0 &&
(mod&ActionEvent.META_MASK)==0)
) {
String command = e.getActionCommand();
RTextArea.addToCurrentMacro(macroID, command);
//System.err.println("... recording it!");
}
}
actionPerformedImpl(e, textArea);
}
}
示例8: actionPerformed
import java.awt.event.ActionEvent; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent event) {
if (!listeners.isEmpty()) {
ActionEvent e = new ActionEvent(menuItem, event.getID(), event.getActionCommand(), event.getWhen(),
event.getModifiers());
for (ActionListener l : listeners) {
l.actionPerformed(e);
}
}
}
示例9: actionPerformed
import java.awt.event.ActionEvent; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent evt) {
boolean editors = true;
boolean views = !documentsOnly;
if( "immediately".equals( evt.getActionCommand() ) ) {
TopComponent activeTc = TopComponent.getRegistry().getActivated();
if( null != activeTc ) {
if( TopComponentTracker.getDefault().isEditorTopComponent( activeTc ) ) {
//switching in a document, go to some other document
views = false;
} else {
//switching in a view, go to some other view
editors = false;
views = true;
}
}
}
TopComponent[] documents = getRecentWindows(editors, views);
if (documents.length < 2) {
return;
}
if(!"immediately".equals(evt.getActionCommand()) && // NOI18N
!(evt.getSource() instanceof javax.swing.JMenuItem)) {
// #46800: fetch key directly from action command
KeyStroke keyStroke = Utilities.stringToKey(evt.getActionCommand());
if(keyStroke != null) {
int triggerKey = keyStroke.getKeyCode();
int reverseKey = KeyEvent.VK_SHIFT;
int releaseKey = 0;
int modifiers = keyStroke.getModifiers();
if((InputEvent.CTRL_MASK & modifiers) != 0) {
releaseKey = KeyEvent.VK_CONTROL;
} else if((InputEvent.ALT_MASK & modifiers) != 0) {
releaseKey = KeyEvent.VK_ALT;
} else if((InputEvent.META_MASK & modifiers) != 0) {
releaseKey = KeyEvent.VK_META;
}
if(releaseKey != 0) {
if (!KeyboardPopupSwitcher.isShown()) {
KeyboardPopupSwitcher.showPopup(documentsOnly, releaseKey, triggerKey, (evt.getModifiers() & KeyEvent.SHIFT_MASK) == 0);
}
return;
}
}
}
int documentIndex = (evt.getModifiers() & KeyEvent.SHIFT_MASK) == 0 ? 1 : documents.length-1;
TopComponent tc = documents[documentIndex];
// #37226 Unmaximized the other mode if needed.
WindowManagerImpl wm = WindowManagerImpl.getInstance();
ModeImpl mode = (ModeImpl) wm.findMode(tc);
if(mode != null && mode != wm.getCurrentMaximizedMode()) {
wm.switchMaximizedMode(null);
}
tc.requestActive();
}
示例10: actionPerformed
import java.awt.event.ActionEvent; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
ActionEvent event = new ActionEvent(source, e.getID(), e.getActionCommand(), e.getWhen(), e.getModifiers());
scrollAction.actionPerformed(event);
}
示例11: actionPerformed
import java.awt.event.ActionEvent; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent evt) {
List<DVThread> threads = getThreads();
int threadsCount = threads.size();
if (threadsCount < 1) {
Toolkit.getDefaultToolkit().beep();
return;
}
if(!"immediately".equals(evt.getActionCommand()) && // NOI18N
!(evt.getSource() instanceof javax.swing.JMenuItem)) {
// #46800: fetch key directly from action command
KeyStroke keyStroke = Utilities.stringToKey(evt.getActionCommand());
if(keyStroke != null) {
int triggerKey = keyStroke.getKeyCode();
int releaseKey = 0;
int modifiers = keyStroke.getModifiers();
if((InputEvent.CTRL_MASK & modifiers) != 0) {
releaseKey = KeyEvent.VK_CONTROL;
} else if((InputEvent.ALT_MASK & modifiers) != 0) {
releaseKey = KeyEvent.VK_ALT;
} else if((InputEvent.META_MASK & modifiers) != 0) {
releaseKey = InputEvent.META_MASK;
}
if(releaseKey != 0) {
if (!KeyboardPopupSwitcher.isShown()) {
KeyboardPopupSwitcher.selectItem(
createSwitcherItems(threads),
releaseKey, triggerKey, true, true); // (evt.getModifiers() & KeyEvent.SHIFT_MASK) == 0
}
return;
}
}
}
if (threadsCount == 1) {
threads.get(0).makeCurrent();
} else {
int index = (evt.getModifiers() & KeyEvent.SHIFT_MASK) == 0 ? 1 : threadsCount - 1;
threads.get(index).makeCurrent();
}
}
示例12: isCTRLPressed
import java.awt.event.ActionEvent; //导入方法依赖的package包/类
public static boolean isCTRLPressed(ActionEvent e) {
return (e.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK;
}