Пример #1
0
 /**
  * Installs the necessary Listeners on the parent <code>Window</code>, if there is one.
  *
  * <p>This takes the parent so that cleanup can be done from <code>removeNotify</code>, at which
  * point the parent hasn't been reset yet.
  *
  * @param parent The parent of the JRootPane
  */
 private void installWindowListeners(JRootPane root, Component parent) {
   if (parent instanceof Window) {
     window = (Window) parent;
   } else {
     window = SwingUtilities.getWindowAncestor(parent);
   }
   if (window != null) {
     if (mouseInputListener == null) {
       mouseInputListener = createWindowMouseInputListener(root);
     }
     window.addMouseListener(mouseInputListener);
     window.addMouseMotionListener(mouseInputListener);
   }
 }
Пример #2
0
  // init
  public void init() {
    super.init();
    mouse = new Point();
    center = new Point();
    image = new Point();
    centering = false;

    try {
      robot = new Robot();
      recenterMouse();
      mouse.x = center.x;
      mouse.y = center.y;
    } catch (Exception e) {
      System.out.println("Exception 1");
    }

    Window w = s.getFullScreenWindow();
    w.addMouseMotionListener(this);
    w.addKeyListener(this);
    bg = new ImageIcon("/Users/Ole/Desktop/undefined/images/bg.jpg").getImage();
  }