public static void main(String s[]) {
    initParams(s);
    initAdapters();
    f = new Frame();
    final int[] modifiers = {InputEvent.SHIFT_MASK, InputEvent.CTRL_MASK};
    final String[] modifierNames = {"InputEvent.SHIFT_MASK", "InputEvent.CTRL_MASK"};
    f.setLayout(new FlowLayout());
    f.addMouseWheelListener(
        new MouseWheelListener() {
          public void mouseWheelMoved(MouseWheelEvent e) {
            System.out.println("WHEEL " + e);
          }
        });
    f.setSize(300, 300);
    f.setVisible(true);

    try {
      robot = new Robot();
      robot.delay(500);
      robot.mouseMove(
          f.getLocationOnScreen().x + f.getWidth() / 2,
          f.getLocationOnScreen().y + f.getHeight() / 2);
      if (autorun) {
        // testing buttons 1, 2, 3 only
        testPlainButtons();
        robot.delay(500);

        // testing buttons 1, 2, 3 with SHIFT, CTRL, ALT keyboard modifiers
        testButtonsWithShift();
        robot.delay(500);

        testButtonsWithControl();
        robot.delay(500);

        testButtonsWithAlt();
        robot.delay(500);
      } else {
        switch (testModifier) {
          case SHIFT:
            f.addMouseListener(adapterTest2);
            break;
          case CTRL:
            f.addMouseListener(adapterTest3);
            break;
          case ALT:
            f.addMouseListener(adapterTest4);
            break;
          default: // NONE inclusive
            f.addMouseListener(adapterTest1);
        }
      }
    } catch (Exception e) {
      throw new RuntimeException("Test failed.");
    }
  }
 // test BUTTON1, 2 and 3 without any modifiers keys
 public static void testPlainButtons() {
   System.out.println("Testing buttons without modifiers.");
   f.addMouseListener(adapterTest1);
   for (int button : mouseButtons) {
     robot.mousePress(button);
     robot.delay(100);
     robot.mouseRelease(button);
   }
   robot.delay(1000);
   f.removeMouseListener(adapterTest1);
 }
 // test BUTTON1, 2 and 3 with ALT key
 public static void testButtonsWithAlt() {
   System.out.println("Testing buttons with ALT modifier.");
   f.addMouseListener(adapterTest4);
   for (int button : mouseButtons) {
     robot.keyPress(KeyEvent.VK_ALT);
     robot.mousePress(button);
     robot.delay(100);
     robot.mouseRelease(button);
     robot.keyRelease(KeyEvent.VK_ALT);
   }
   robot.delay(1000);
   f.removeMouseListener(adapterTest4);
 }