本文整理汇总了Java中java.awt.Robot.waitForIdle方法的典型用法代码示例。如果您正苦于以下问题:Java Robot.waitForIdle方法的具体用法?Java Robot.waitForIdle怎么用?Java Robot.waitForIdle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Robot
的用法示例。
在下文中一共展示了Robot.waitForIdle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import java.awt.Robot; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Robot robot = new Robot();
SwingUtilities.invokeAndWait(() -> {
frame = new JFrame();
frame.setSize(500, 500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
tabbedPane = new JTabbedPane();
for (int i = 0; i < TAB_COUNT; i++) {
tabbedPane.add("Header " + i, new JLabel("Content: " + i));
}
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(tabbedPane, BorderLayout.CENTER);
frame.setVisible(true);
});
robot.waitForIdle();
SwingUtilities.invokeAndWait(() -> {
for (int j = 0; j < ITERATIONS; j++) {
for (int i = 0; i < TAB_COUNT; i++) {
tabbedPane.setTitleAt(i, getHtmlText(j * TAB_COUNT + i));
}
}
});
robot.waitForIdle();
SwingUtilities.invokeAndWait(() -> frame.dispose());
}
示例2: test
import java.awt.Robot; //导入方法依赖的package包/类
private void test() throws AWTException, InterruptedException, InvocationTargetException {
Robot robot = new Robot();
robot.setAutoDelay(50);
robot.waitForIdle();
Util.hitMnemonics(robot, KeyEvent.VK_1);
robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
if (!menu.isSelected()) {
throw new RuntimeException(
"Failed: Menu didn't remain posted at end of test");
} else {
System.out.println("Test passed!");
frame.dispose();
}
}
});
}
示例3: 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());
}
}
示例4: main
import java.awt.Robot; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
robot = new Robot();
UIManager.LookAndFeelInfo[] lookAndFeelArray
= UIManager.getInstalledLookAndFeels();
for (UIManager.LookAndFeelInfo lookAndFeelItem : lookAndFeelArray) {
String lookAndFeelString = lookAndFeelItem.getClassName();
if (tryLookAndFeel(lookAndFeelString)) {
createUI();
performTest();
robot.waitForIdle();
}
}
if (!"".equals(errorMessage)) {
throw new RuntimeException(errorMessage);
}
}
示例5: main
import java.awt.Robot; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Frame frame = new Frame();
Robot robot = new Robot();
final Toolkit toolkit = Toolkit.getDefaultToolkit();
final GraphicsEnvironment graphicsEnvironment =
GraphicsEnvironment.getLocalGraphicsEnvironment();
final GraphicsDevice graphicsDevice =
graphicsEnvironment.getDefaultScreenDevice();
final Dimension screenSize = toolkit.getScreenSize();
final Insets screenInsets = toolkit.getScreenInsets(
graphicsDevice.getDefaultConfiguration());
final Rectangle availableScreenBounds = new Rectangle(screenSize);
availableScreenBounds.x += screenInsets.left;
availableScreenBounds.y += screenInsets.top;
availableScreenBounds.width -= (screenInsets.left + screenInsets.right);
availableScreenBounds.height -= (screenInsets.top + screenInsets.bottom);
frame.setBounds(availableScreenBounds.x, availableScreenBounds.y,
availableScreenBounds.width, availableScreenBounds.height);
frame.setVisible(true);
robot.waitForIdle();
Rectangle frameBounds = frame.getBounds();
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
robot.waitForIdle();
Rectangle maximizedFrameBounds = frame.getBounds();
frame.dispose();
if (maximizedFrameBounds.width < frameBounds.width
|| maximizedFrameBounds.height < frameBounds.height) {
throw new RuntimeException("Maximized frame is smaller than non maximized");
}
}
示例6: main
import java.awt.Robot; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
robot = new Robot();
EventQueue.invokeAndWait(DockIconRepaint::createUI);
try {
robot.waitForIdle();
color = Color.BLUE;
test();
color = Color.RED;
test();
color = Color.GREEN;
test();
} finally {
frame.dispose();
}
}
示例7: main
import java.awt.Robot; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
Robot robot = new Robot();
robot.setAutoDelay(50);
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
robot.waitForIdle();
clickMouse(robot, 0, 0);
Util.hitKeys(robot, KeyEvent.VK_A, KeyEvent.VK_B, KeyEvent.VK_ENTER);
robot.waitForIdle();
checkCell(0, 0);
clickMouse(robot, 0, 1);
Util.hitKeys(robot, KeyEvent.VK_D, KeyEvent.VK_E, KeyEvent.VK_ENTER);
robot.waitForIdle();
checkCell(0, 1);
clickMouse(robot, 1, 0);
Util.hitKeys(robot, KeyEvent.VK_1, KeyEvent.VK_2, KeyEvent.VK_ENTER);
robot.waitForIdle();
checkCell(1, 0);
clickMouse(robot, 1, 1);
Util.hitKeys(robot, KeyEvent.VK_4, KeyEvent.VK_5, KeyEvent.VK_ENTER);
robot.waitForIdle();
checkCell(1, 1);
}
示例8: main
import java.awt.Robot; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Frame frame = new Frame();
frame.setSize(300, 300);
frame.setVisible(true);
Robot robot = new Robot();
robot.setAutoDelay(50);
robot.waitForIdle();
robot.keyPress(KeyEvent.VK_DELETE);
robot.keyRelease(KeyEvent.VK_DELETE);
robot.waitForIdle();
frame.dispose();
if (eventsCount != 3) {
throw new RuntimeException("Wrong number of key events: " + eventsCount);
}
}
示例9: main
import java.awt.Robot; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
SwingUtilities.invokeLater(SelectAllFilesFilterTest::createAndShowGUI);
while (fileChooser == null) {
Thread.sleep(100);
}
Robot robot = new Robot();
robot.waitForIdle();
SwingUtilities.invokeAndWait(() -> {
comboBox = findComboBox(fileChooser);
comboBox.setSelectedIndex(0);
});
robot.waitForIdle();
SwingUtilities.invokeAndWait(() -> {
int selectedIndex = comboBox.getSelectedIndex();
fileChooser.setVisible(false);
if (selectedIndex != 0) {
throw new RuntimeException("Select All file filter is not selected!");
}
});
}
示例10: main
import java.awt.Robot; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
robot = new Robot();
String name = UIManager.getSystemLookAndFeelClassName();
try {
UIManager.setLookAndFeel(name);
} catch (ClassNotFoundException | InstantiationException |
IllegalAccessException | UnsupportedLookAndFeelException e) {
throw new RuntimeException("Test Failed");
}
createUI();
robot.waitForIdle();
executeTest();
if (!"".equals(errorMessage)) {
throw new RuntimeException(errorMessage);
}
}
示例11: main
import java.awt.Robot; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Frame frame = new Frame();
frame.setSize(300, 200);
TextField textField = new TextField();
frame.add(textField);
Robot robot = new Robot();
robot.setAutoDelay(50);
frame.setVisible(true);
robot.waitForIdle();
textField.requestFocus();
robot.waitForIdle();
// Check that the system assertion dialog does not block Java
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);
robot.waitForIdle();
frame.setVisible(false);
frame.dispose();
}
示例12: 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);
}
示例13: main
import java.awt.Robot; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
robot = new Robot();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
try {
JOptionPane optionPane = new JOptionPane("JOptionPane",
JOptionPane.INFORMATION_MESSAGE,
JOptionPane.DEFAULT_OPTION,
null,
new String[]{"3", "2", "1"},
null);
dialog = optionPane.createDialog("JOptionPane");
int width = 0;
Component[] comps = optionPane.getComponents();
for (Component comp : comps) {
if (comp instanceof JPanel) {
Component[] child = ((JPanel) comp).getComponents();
for (Component c : child) {
if (c instanceof JButton) {
width += c.getWidth();
}
}
}
}
Insets in = optionPane.getInsets();
width += in.left + in.right;
if (width > optionPane.getWidth()) {
testFailed = true;
}
} finally {
dialog.dispose();
}
}
});
robot.waitForIdle();
if (testFailed) {
throw new RuntimeException("Test Failed");
}
}
示例14: hitKey
import java.awt.Robot; //导入方法依赖的package包/类
private static void hitKey(Robot robot, int mode, int keycode) {
robot.keyPress(mode);
robot.keyPress(keycode);
robot.keyRelease(mode);
robot.keyRelease(keycode);
robot.waitForIdle();
}
示例15: sleep
import java.awt.Robot; //导入方法依赖的package包/类
private static void sleep(Robot robot) {
robot.waitForIdle();
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
}
}