本文整理汇总了Java中java.awt.Robot.mouseWheel方法的典型用法代码示例。如果您正苦于以下问题:Java Robot.mouseWheel方法的具体用法?Java Robot.mouseWheel怎么用?Java Robot.mouseWheel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Robot
的用法示例。
在下文中一共展示了Robot.mouseWheel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import java.awt.Robot; //导入方法依赖的package包/类
private static void test(GraphicsConfiguration gc) throws AWTException {
final Window frame = new Frame(gc);
try {
frame.addMouseWheelListener(e -> {
wheelX = e.getXOnScreen();
wheelY = e.getYOnScreen();
done = true;
});
frame.setSize(300, 300);
frame.setVisible(true);
final Robot robot = new Robot();
robot.setAutoDelay(50);
robot.setAutoWaitForIdle(true);
mouseX = frame.getX() + frame.getWidth() / 2;
mouseY = frame.getY() + frame.getHeight() / 2;
robot.mouseMove(mouseX, mouseY);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseWheel(10);
validate();
} finally {
frame.dispose();
}
}
示例2: ContextMenuScrollTest
import java.awt.Robot; //导入方法依赖的package包/类
public ContextMenuScrollTest() throws Exception
{
robot = new Robot();
robot.setAutoDelay(200);
try {
SwingUtilities.invokeAndWait(()->createGUI());
blockTillDisplayed(menu);
robot.waitForIdle();
robot.mouseMove(p.x + d.width/2, p.y + d.height/2);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.waitForIdle();
System.out.println("popmenu visible " + menu.isPopupMenuVisible());
robot.mouseWheel(1);
robot.waitForIdle();
System.out.println("popmenu visible " + menu.isPopupMenuVisible());
if (!menu.isPopupMenuVisible()) {
throw new RuntimeException("Popup closes on mouse scroll");
}
} finally {
SwingUtilities.invokeAndWait(()->frame.dispose());
}
}
示例3: test
import java.awt.Robot; //导入方法依赖的package包/类
private static void test(Robot robot) throws Exception {
SwingUtilities.invokeAndWait(() -> {
Point locationOnScreen = scrollPane.getLocationOnScreen();
point = new Point(
locationOnScreen.x + scrollPane.getWidth() / 2,
locationOnScreen.y + scrollPane.getHeight() / 2);
});
robot.mouseMove(point.x, point.y);
robot.waitForIdle();
// vertical scroll bar is enabled
initScrollPane(true, false);
robot.waitForIdle();
robot.mouseWheel(delta);
robot.waitForIdle();
checkScrollPane(true, false);
// vertical scroll bar is enabled + shift
initScrollPane(true, false);
robot.waitForIdle();
robot.keyPress(KeyEvent.VK_SHIFT);
robot.mouseWheel(delta);
robot.keyRelease(KeyEvent.VK_SHIFT);
robot.waitForIdle();
checkScrollPane(false, false);
// horizontal scroll bar is enabled
initScrollPane(false, true);
robot.waitForIdle();
robot.mouseWheel(delta);
robot.waitForIdle();
checkScrollPane(false, true);
// horizontal scroll bar is enabled + shift
initScrollPane(false, true);
robot.waitForIdle();
robot.keyPress(KeyEvent.VK_SHIFT);
robot.mouseWheel(delta);
robot.keyRelease(KeyEvent.VK_SHIFT);
robot.waitForIdle();
checkScrollPane(false, true);
// both scroll bars are enabled
initScrollPane(true, true);
robot.waitForIdle();
robot.mouseWheel(delta);
robot.waitForIdle();
checkScrollPane(true, false);
// both scroll bars are enabled + shift
initScrollPane(true, true);
robot.waitForIdle();
robot.keyPress(KeyEvent.VK_SHIFT);
robot.mouseWheel(delta);
robot.keyRelease(KeyEvent.VK_SHIFT);
robot.waitForIdle();
checkScrollPane(false, true);
}