当前位置: 首页>>代码示例>>Java>>正文


Java Robot.mouseWheel方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:MouseWheelAbsXY.java

示例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());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:ContextMenuScrollTest.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:60,代码来源:HorizontalMouseWheelOnShiftPressed.java


注:本文中的java.awt.Robot.mouseWheel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。