public InputManager(Component component) { this.component = component; mouseLocation = new Point(); centerLocation = new Point(); component.addKeyListener(this); component.addMouseListener(this); component.addMouseMotionListener(this); component.addMouseWheelListener(this); component.setFocusTraversalKeysEnabled(false); }
public InputManager(Component comp) { this.comp = comp; mousePosition = new Point(); centerLocation = new Point(); // register Listeners comp.addKeyListener(this); comp.addMouseListener(this); comp.addMouseMotionListener(this); comp.addMouseWheelListener(this); // tell focus traversal to take a hike! comp.setFocusTraversalKeysEnabled(false); }
/** Creates a new InputManager that listens to input from the specified component. */ public InputManager(Component comp) { this.comp = comp; mouseLocation = new Point(); centerLocation = new Point(); // register key and mouse listeners comp.addKeyListener(this); comp.addMouseListener(this); comp.addMouseMotionListener(this); comp.addMouseWheelListener(this); // allow input of the TAB key and other keys normally // used for focus traversal comp.setFocusTraversalKeysEnabled(false); }
/** * 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); }
private void initMouseListeners(Component component) { component.addMouseMotionListener( new MouseMotionAdapter() { @Override public void mouseDragged(MouseEvent e) { if (dragstart != null) { switch (dragmode) { case DRAG_ROTATE: rotx += e.getY() - dragstart.getY(); roty += e.getX() - dragstart.getX(); break; case DRAG_ZOOM: z += (e.getY() - dragstart.getY()) / 5.0f; break; } } dragstart = e.getPoint(); } }); component.addMouseWheelListener( new MouseWheelListener() { public void mouseWheelMoved(MouseWheelEvent e) { z += e.getWheelRotation() * 5; } }); component.addMouseListener( new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { switch (e.getButton()) { case (MouseEvent.BUTTON1): dragmode = MOUSE_MODE.DRAG_ROTATE; break; case (MouseEvent.BUTTON2): dragmode = MOUSE_MODE.DRAG_ZOOM; break; case (MouseEvent.BUTTON3): dragmode = MOUSE_MODE.DRAG_ZOOM; break; } } @Override public void mouseReleased(MouseEvent e) { switch (e.getButton()) { case (MouseEvent.BUTTON1): dragmode = MOUSE_MODE.DRAG_ZOOM; break; case (MouseEvent.BUTTON2): dragmode = MOUSE_MODE.DRAG_ROTATE; break; case (MouseEvent.BUTTON3): dragmode = MOUSE_MODE.DRAG_ROTATE; break; } dragstart = null; } }); }
/** * @see JPanel#addMouseWheelListener(MouseWheelListener) * @param mwl mouse wheel listener */ public void addMouseWheelListener(MouseWheelListener mwl) { canvas.addMouseWheelListener(mwl); }