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