本文整理汇总了Java中java.awt.event.InputEvent类的典型用法代码示例。如果您正苦于以下问题:Java InputEvent类的具体用法?Java InputEvent怎么用?Java InputEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InputEvent类属于java.awt.event包,在下文中一共展示了InputEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: URIListToFileListBetweenJVMsTest
import java.awt.event.InputEvent; //导入依赖的package包/类
public URIListToFileListBetweenJVMsTest(Point targetFrameLocation,
Point dragSourcePoint,
int transferredFilesNumber) throws InterruptedException
{
TargetFileListFrame targetFrame = new TargetFileListFrame(targetFrameLocation, transferredFilesNumber);
Util.waitForIdle(null);
final Robot robot = Util.createRobot();
robot.mouseMove((int)dragSourcePoint.getX(),(int)dragSourcePoint.getY());
sleep(100);
robot.mousePress(InputEvent.BUTTON1_MASK);
sleep(100);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
sleep(100);
Util.drag(robot, dragSourcePoint, targetFrame.getDropTargetPoint(), InputEvent.BUTTON1_MASK);
}
示例2: keyPressed
import java.awt.event.InputEvent; //导入依赖的package包/类
public State keyPressed (Widget widget, WidgetKeyEvent event) {
if (event.getKeyCode () == KeyEvent.VK_CONTEXT_MENU || ((event.getModifiers () & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK && event.getKeyCode () == KeyEvent.VK_F10)) {
JPopupMenu popupMenu = provider.getPopupMenu (widget, null);
if (popupMenu != null) {
JComponent view = widget.getScene ().getView ();
if (view != null) {
// Rectangle visibleRect = view.getVisibleRect ();
// popupMenu.show (view, visibleRect.x + 10, visibleRect.y + 10);
Rectangle bounds = widget.getBounds ();
Point location = new Point (bounds.x + 5, bounds.y + 5);
location = widget.convertLocalToScene (location);
location = widget.getScene ().convertSceneToView (location);
popupMenu.show (view, location.x, location.y);
}
}
return State.CONSUMED;
}
return State.REJECTED;
}
示例3: mouseWheelMoved
import java.awt.event.InputEvent; //导入依赖的package包/类
public State mouseWheelMoved (Widget widget, WidgetMouseWheelEvent event) {
JComponent view = widget.getScene ().getView ();
Rectangle visibleRect = view.getVisibleRect ();
int amount = event.getWheelRotation () * 64;
switch (event.getModifiers () & (InputEvent.SHIFT_MASK | InputEvent.CTRL_MASK | InputEvent.ALT_MASK)) {
case InputEvent.SHIFT_MASK:
visibleRect.x += amount;
break;
case 0:
visibleRect.y += amount;
break;
default:
return State.REJECTED;
}
view.scrollRectToVisible (visibleRect);
return State.CONSUMED;
}
示例4: main
import java.awt.event.InputEvent; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(() -> {
new RemovedComponentMouseListener();
});
Robot r = Util.createRobot();
r.setAutoDelay(100);
r.waitForIdle();
Util.pointOnComp(button, r);
r.waitForIdle();
r.mousePress(InputEvent.BUTTON1_MASK);
r.waitForIdle();
r.mouseRelease(InputEvent.BUTTON1_MASK);
r.waitForIdle();
if (!mouseReleasedReceived) {
throw new RuntimeException("mouseReleased event was not received");
}
}
示例5: getPieceValueMask
import java.awt.event.InputEvent; //导入依赖的package包/类
public Obscurable getPieceValueMask() throws IOException {
if (getOwner().useHiddenPieces()) {
SequenceEncoder se = new SequenceEncoder(';');
se.append(new NamedKeyStroke(KeyStroke.getKeyStroke('I', InputEvent.CTRL_MASK))); // key command
se.append(getImageName()); // hide image
se.append("Hide Info"); // menu name
BufferedImage image = getSymbol().getImage();
se.append("G" + getFlagLayer(new Dimension(image.getWidth(), image.getHeight()), StateFlag.INFO)); // display style
if (name == null)
se.append(getName());
else
se.append("Unknown Piece"); // mask name
se.append("sides:" + getOwner().getName()); // owning player
Obscurable p = new Obscurable();
p.mySetType(Obscurable.ID + se.getValue());
return p;
}
else {
return null;
}
}
示例6: updateMouse
import java.awt.event.InputEvent; //导入依赖的package包/类
private void updateMouse(Canvas canvas, int mx, int my, int mods) {
if (active) {
boolean shift = (mods & InputEvent.SHIFT_DOWN_MASK) != 0;
Location newEnd;
if (shift) {
newEnd = LineUtil.snapTo8Cardinals(mouseStart, mx, my);
} else {
newEnd = Location.create(mx, my);
}
if ((mods & InputEvent.CTRL_DOWN_MASK) == 0) {
int x = newEnd.getX();
int y = newEnd.getY();
x = canvas.snapX(x);
y = canvas.snapY(y);
newEnd = Location.create(x, y);
}
if (!newEnd.equals(mouseEnd)) {
mouseEnd = newEnd;
repaintArea(canvas);
}
}
lastMouseX = mx;
lastMouseY = my;
}
示例7: keyTyped
import java.awt.event.InputEvent; //导入依赖的package包/类
@Override
public void keyTyped(KeyEvent e) {
int ign = InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK | InputEvent.META_DOWN_MASK;
if ((e.getModifiersEx() & ign) != 0)
return;
char c = e.getKeyChar();
if (c == '\n') {
stopEditing();
} else if (c != KeyEvent.CHAR_UNDEFINED && !Character.isISOControl(c)) {
if (pos < curText.length()) {
curText = curText.substring(0, pos) + c + curText.substring(pos);
} else {
curText += c;
}
++pos;
field.setText(curText);
}
}
示例8: initLegalButtonMask
import java.awt.event.InputEvent; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private static synchronized void initLegalButtonMask() {
if (LEGAL_BUTTON_MASK != 0) return;
int tmpMask = 0;
if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
if (Toolkit.getDefaultToolkit() instanceof SunToolkit) {
final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
for (int i = 0; i < buttonsNumber; i++){
tmpMask |= InputEvent.getMaskForButton(i+1);
}
}
}
tmpMask |= InputEvent.BUTTON1_MASK|
InputEvent.BUTTON2_MASK|
InputEvent.BUTTON3_MASK|
InputEvent.BUTTON1_DOWN_MASK|
InputEvent.BUTTON2_DOWN_MASK|
InputEvent.BUTTON3_DOWN_MASK;
LEGAL_BUTTON_MASK = tmpMask;
}
示例9: clickOnComp
import java.awt.event.InputEvent; //导入依赖的package包/类
/**
* Moves mouse pointer in the center of a given {@code comp} component
* and performs a left mouse button click using the {@code robot} parameter
* with the {@code delay} delay between press and release.
*/
public static void clickOnComp(final Component comp, final Robot robot, int delay) {
pointOnComp(comp, robot);
robot.delay(delay);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.delay(delay);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
示例10: handleScrollEvent
import java.awt.event.InputEvent; //导入依赖的package包/类
/**
* Handles scroll events.
*/
void handleScrollEvent(final int x, final int y, final int modifierFlags,
final double deltaX, final double deltaY) {
final int buttonNumber = CocoaConstants.kCGMouseButtonCenter;
int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber,
modifierFlags);
final boolean isShift = (jmodifiers & InputEvent.SHIFT_DOWN_MASK) != 0;
// Vertical scroll.
if (!isShift && deltaY != 0.0) {
dispatchScrollEvent(x, y, jmodifiers, deltaY);
}
// Horizontal scroll or shirt+vertical scroll.
final double delta = isShift && deltaY != 0.0 ? deltaY : deltaX;
if (delta != 0.0) {
jmodifiers |= InputEvent.SHIFT_DOWN_MASK;
dispatchScrollEvent(x, y, jmodifiers, delta);
}
}
示例11: mouseDND
import java.awt.event.InputEvent; //导入依赖的package包/类
public static void mouseDND(Robot robot, int x1, int y1, int x2, int y2) {
int N = 20;
int x = x1;
int y = y1;
int dx = (x2 - x1) / N;
int dy = (y2 - y1) / N;
robot.mousePress(InputEvent.BUTTON1_MASK);
for (int i = 0; i < N; i++) {
robot.mouseMove(x += dx, y += dy);
}
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
示例12: setOldModifiers
import java.awt.event.InputEvent; //导入依赖的package包/类
/**
* Sets old modifiers by the new ones.
*/
@SuppressWarnings("deprecation")
private void setOldModifiers() {
if ((gestureModifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) {
gestureModifiers |= InputEvent.BUTTON1_MASK;
}
if ((gestureModifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) {
gestureModifiers |= InputEvent.BUTTON2_MASK;
}
if ((gestureModifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) {
gestureModifiers |= InputEvent.BUTTON3_MASK;
}
if ((gestureModifiers & InputEvent.SHIFT_DOWN_MASK) != 0) {
gestureModifiers |= InputEvent.SHIFT_MASK;
}
if ((gestureModifiers & InputEvent.CTRL_DOWN_MASK) != 0) {
gestureModifiers |= InputEvent.CTRL_MASK;
}
if ((gestureModifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) {
gestureModifiers |= InputEvent.ALT_GRAPH_MASK;
}
}
示例13: fromString
import java.awt.event.InputEvent; //导入依赖的package包/类
public static int fromString(String str) {
int ret = 0;
StringTokenizer toks = new StringTokenizer(str);
while (toks.hasMoreTokens()) {
String s = toks.nextToken();
if (s.equals(CTRL))
ret |= InputEvent.CTRL_DOWN_MASK;
else if (s.equals(SHIFT))
ret |= InputEvent.SHIFT_DOWN_MASK;
else if (s.equals(ALT))
ret |= InputEvent.ALT_DOWN_MASK;
else if (s.equals(BUTTON1))
ret |= InputEvent.BUTTON1_DOWN_MASK;
else if (s.equals(BUTTON2))
ret |= InputEvent.BUTTON2_DOWN_MASK;
else if (s.equals(BUTTON3))
ret |= InputEvent.BUTTON3_DOWN_MASK;
else
throw new NumberFormatException("InputEventUtil");
}
return ret;
}
示例14: dispatchKeyEvent
import java.awt.event.InputEvent; //导入依赖的package包/类
@Override
public boolean dispatchKeyEvent(java.awt.event.KeyEvent e) {
boolean isCtrl = e.getModifiers() == InputEvent.CTRL_MASK;
boolean isCtrlShift = e.getModifiers() == (InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK);
boolean doPopup = (e.getKeyCode() == KeyEvent.VK_TAB) &&
(isCtrl || isCtrlShift);
if (doPopup && !KeyboardPopupSwitcher.isShown()) {
// create popup with our SwitcherTable
KeyboardPopupSwitcher.showPopup(new Model( items1, items2, true ), KeyEvent.VK_CONTROL, e.getKeyCode(), (e.getModifiers() & InputEvent.SHIFT_MASK)==0);
return true;
}
if( KeyboardPopupSwitcher.isShown() ) {
KeyboardPopupSwitcher.doProcessShortcut( e );
}
return false;
}
示例15: enteredGeneratesSameEvents
import java.awt.event.InputEvent; //导入依赖的package包/类
public void enteredGeneratesSameEvents() throws Throwable {
events = MouseEvent.MOUSE_ENTERED;
SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() {
actionsArea.setText("");
}
});
driver = new JavaDriver();
WebElement b = driver.findElement(By.name("click-me"));
WebElement t = driver.findElement(By.name("actions"));
Point location = EventQueueWait.call_noexc(button, "getLocationOnScreen");
Dimension size = EventQueueWait.call_noexc(button, "getSize");
Robot r = new Robot();
r.setAutoDelay(10);
r.setAutoWaitForIdle(true);
r.keyPress(KeyEvent.VK_ALT);
r.mouseMove(location.x + size.width / 2, location.y + size.height / 2);
r.mousePress(InputEvent.BUTTON1_MASK);
r.mouseRelease(InputEvent.BUTTON1_MASK);
r.keyRelease(KeyEvent.VK_ALT);
new EventQueueWait() {
@Override public boolean till() {
return actionsArea.getText().length() > 0;
}
}.wait("Waiting for actionsArea failed?");
String expected = t.getText();
tclear();
Point location2 = EventQueueWait.call_noexc(actionsArea, "getLocationOnScreen");
Dimension size2 = EventQueueWait.call_noexc(actionsArea, "getSize");
r.mouseMove(location2.x + size2.width / 2, location2.y + size2.height / 2);
r.mousePress(InputEvent.BUTTON1_MASK);
r.mouseRelease(InputEvent.BUTTON1_MASK);
new Actions(driver).moveToElement(t).keyDown(Keys.ALT).moveToElement(b).click().keyUp(Keys.ALT).perform();
AssertJUnit.assertEquals(expected, t.getText());
}