예제 #1
0
  @Override
  protected void addImpl(final Component comp, Object constraints, int index) {
    super.addImpl(comp, constraints, index);

    comp.addMouseMotionListener(
        new MouseAdapter() {
          @Override
          public void mouseMoved(MouseEvent e) {
            lastScreen =
                componentToImage(comp, new Rectangle(0, 0, comp.getWidth(), comp.getHeight()));
          }
        });
    comp.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            setBorder(new ResizableBorder(6));
          }

          @Override
          public void mousePressed(MouseEvent e) {
            mouse = true;
          }

          @Override
          public void mouseReleased(MouseEvent e) {
            mouse = false;
          }
        });
  }
  public void attachTo(@Nullable Component owner, @Nullable Component mouseTarget) {
    if (myMouseTarget != null) {
      myClickListener.uninstall(myMouseTarget);
      myMouseTarget.removeMouseMotionListener(myMouseMotionListener);
    }

    myOwner = owner;
    myMouseTarget = mouseTarget;

    if (myMouseTarget != null) {
      myClickListener.installOn(myMouseTarget);
      myMouseTarget.addMouseMotionListener(myMouseMotionListener);
    }
  }
  /**
   * Constructor.
   *
   * @param eventSource source of the mouse and key events which will be translated into scripting
   *     language commands. Such a typical source is e.g. the VNC viewer panel.
   */
  public RecordingModule(
      MainFrame frame, Component eventSource, ScriptManager scriptManager, UserConfiguration cfg) {
    this.cfg = cfg;
    this.scriptManager = scriptManager;
    readOnly = cfg.getBoolean("rfb.readOnly").booleanValue();

    fb = (DesktopViewer) eventSource;
    fb.removeMouseListener(fb);
    eventSource.addMouseListener(this);
    fb.addMouseListener(fb);
    eventSource.addMouseMotionListener(this);
    eventSource.addMouseWheelListener(this);
    eventSource.addKeyListener(this);

    client = scriptManager.getClient();
    if (client != null) {
      client.addServerListener(this);
    }

    //        scriptManager.addMouseInputListener(this);
    //        scriptManager.addKeyListener(this);

    // Number of archived events
    //        events.setSize(EVENT_VECTOR_SIZE);

    // Populate the reversed keycode->keyname Map
    Map t = Utils.getKeyCodeTable();
    Iterator e = t.keySet().iterator();
    Object o;
    while (e.hasNext()) {
      o = e.next();
      keyCodes.put(t.get(o), o);
    }
    cfg.addConfigurationListener(this);
    scriptManager.addScriptListener(this);
    configurationChanged(null);
  }