當前位置: 首頁>>代碼示例>>Java>>正文


Java InputEvent類代碼示例

本文整理匯總了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);

}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:21,代碼來源:URIListToFileListBetweenJVMsTest.java

示例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;
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:PopupMenuAction.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:WheelPanAction.java

示例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");
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:20,代碼來源:RemovedComponentMouseListener.java

示例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;
  }
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:22,代碼來源:ADC2Module.java

示例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;
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:27,代碼來源:LineTool.java

示例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);
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:20,代碼來源:TextFieldCaret.java

示例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;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:Robot.java

示例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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:Util.java

示例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);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:22,代碼來源:CPlatformResponder.java

示例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);
    }
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:17,代碼來源:MissingEventsOnModalDialogTest.java

示例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;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:DragSourceDragEvent.java

示例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;
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:23,代碼來源:InputEventUtil.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:KeyboardPopupSwitcherTestHid.java

示例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());

}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:39,代碼來源:NativeEventsTest.java


注:本文中的java.awt.event.InputEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。