List of utility methods to do Swing Mouse
MouseEvent | adaptEventToDescendent(MouseEvent e, JComponent descendentTarget) adapt Event To Descendent Point trans = new Point(); Component source = e.getComponent(); Component current = descendentTarget; while (current != source) { Rectangle b = current.getBounds(); trans.x += b.x; trans.y += b.y; current = current.getParent(); ... |
void | addMouseListenerToAll(Component parent, MouseListener listener) add Mouse Listener To All if (parent instanceof AbstractButton) { AbstractButton a = (AbstractButton) parent; boolean is = false; MouseListener[] kl = a.getMouseListeners(); for (MouseListener k : kl) { if (k.equals(listener)) { is = true; break; ... |
void | addMouseListenerToHierarchy(JComponent c, MouseListener listener) add Mouse Listener To Hierarchy for (Component comp : c.getComponents()) { comp.addMouseListener(listener); if (comp instanceof JComponent) { addMouseListenerToHierarchy((JComponent) comp, listener); |
void | animateMouse(Robot robot, JComponent jc, boolean moveMouse, boolean clickOnArrival) Move the mouse to the center of the component provided. Point p = new Point(jc.getWidth() / 2, jc.getHeight() / 2);
animateMouse(robot, jc, p, moveMouse, clickOnArrival ? 1 : 0);
|
boolean | clickedInSelection(MouseEvent e) Tests if one clicked on already selected rows. if (!(e.getSource() instanceof JTable)) return false; JTable invoker = (JTable) e.getSource(); if (invoker.getSelectedRows().length == 0) return false; int clickedRow = invoker.rowAtPoint(e.getPoint()); for (int selectedRow : invoker.getSelectedRows()) { if (selectedRow == clickedRow) ... |
MouseEvent | convert(MouseEvent event, Component newSource) convert return convert(event, newSource,
SwingUtilities.convertPoint((Component) event.getSource(), event.getPoint(), newSource));
|
MouseEvent | convertMouseEvent(Component source, MouseEvent sourceEvent, Component destination) Convert a mouse event which refrers to one component to another. Point newpt = convertPoint(source, sourceEvent.getX(), sourceEvent.getY(), destination); return new MouseEvent(destination, sourceEvent.getID(), sourceEvent.getWhen(), sourceEvent.getModifiers(), newpt.x, newpt.y, sourceEvent.getClickCount(), sourceEvent.isPopupTrigger(), sourceEvent.getButton()); |
MouseEvent | convertMouseEvent(Component source, MouseEvent sourceEvent, Component destination) convert Mouse Event Point p = SwingUtilities.convertPoint(source, new Point(sourceEvent.getX(), sourceEvent.getY()), destination); Component newSource; if (destination != null) newSource = destination; else newSource = source; MouseEvent newEvent; ... |
java.awt.event.MouseEvent | convertMouseEvent(java.awt.Component source, java.awt.event.MouseEvent sourceEvent, java.awt.Component destination) convert Mouse Event int modifiers = sourceEvent.getModifiers(); int modifiersEx = sourceEvent.getModifiersEx(); int modifiersComplete = modifiers | modifiersEx; java.awt.event.MouseEvent me = javax.swing.SwingUtilities.convertMouseEvent(source, sourceEvent, destination); if (me instanceof java.awt.event.MouseWheelEvent) { java.awt.event.MouseWheelEvent mwe = (java.awt.event.MouseWheelEvent) me; return new java.awt.event.MouseWheelEvent(me.getComponent(), me.getID(), me.getWhen(), ... |
Point | convertPoint(MouseEvent evt, Component target) convert Point return SwingUtilities.convertPoint(evt.getComponent(), evt.getPoint(), target);
|