List of usage examples for java.awt.event MouseEvent MouseEvent
public MouseEvent(Component source, int id, long when, int modifiers, int x, int y, int clickCount, boolean popupTrigger)
From source file:SwingGlassExample.java
private void redispatchMouseEvent(MouseEvent e) { boolean inButton = false; boolean inMenuBar = false; Point glassPanePoint = e.getPoint(); Component component = null;/*from w w w. j a v a2 s . c om*/ Container container = contentPane; Point containerPoint = SwingUtilities.convertPoint(this, glassPanePoint, contentPane); int eventID = e.getID(); if (containerPoint.y < 0) { inMenuBar = true; container = menuBar; containerPoint = SwingUtilities.convertPoint(this, glassPanePoint, menuBar); testForDrag(eventID); } //XXX: If the event is from a component in a popped-up menu, //XXX: then the container should probably be the menu's //XXX: JPopupMenu, and containerPoint should be adjusted //XXX: accordingly. component = SwingUtilities.getDeepestComponentAt(container, containerPoint.x, containerPoint.y); if (component == null) { return; } else { inButton = true; testForDrag(eventID); } if (inMenuBar || inButton || inDrag) { Point componentPoint = SwingUtilities.convertPoint(this, glassPanePoint, component); component.dispatchEvent(new MouseEvent(component, eventID, e.getWhen(), e.getModifiers(), componentPoint.x, componentPoint.y, e.getClickCount(), e.isPopupTrigger())); } }
From source file:pl.edu.icm.visnow.lib.basic.viewers.Viewer2D.Display2DPanel.java
private void formMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseMoved int x = evt.getX(); int y = evt.getY(); currentUnderCursorObj = root.getChiltAt(x, y); currentObjectInfo = ""; currentLocalValueInfo = ""; currentLocalPositionInfo = ""; if (currentUnderCursorObj == null || currentUnderCursorObj == root) { fireStateChanged();/*from w w w. j a v a 2 s . co m*/ if (parentFrame != null) { parentFrame.setStatus(""); } tootltipActive = false; this.setToolTipText(null); return; } //System.out.println("clicekd - "+((obj==null)?"<empty>":obj.getName())); currentObjectInfo = "" + currentUnderCursorObj.getName(); int[] p = currentUnderCursorObj.getLocalCoords(x, y); //System.out.println("["+p[0]+","+p[1]+"]"); currentLocalPositionInfo = "[" + p[0] + "," + p[1] + "]"; //System.out.println("local info: " + obj.getGeometryObject2D().getLocalInfoAt(p[0], p[1])); currentLocalValueInfo = currentUnderCursorObj.getGeometryObject2D().getLocalInfoAt(p[0], p[1]); fireStateChanged(); if (parentFrame != null) { parentFrame.setStatus( "" + currentObjectInfo + " | " + currentLocalPositionInfo + " | " + currentLocalValueInfo); } if (tootltipActive) { this.setToolTipText(currentUnderCursorObj.getGeometryObject2D().getDetailedLocalInfoAt(p[0], p[1])); ToolTipManager.sharedInstance().setInitialDelay(0); ToolTipManager.sharedInstance().setDismissDelay(100000); ToolTipManager.sharedInstance().mouseMoved(new MouseEvent(this, 0, 0, 0, x, y, // X-Y of the mouse for the tool tip 0, false)); } else { this.setToolTipText(null); } }
From source file:nl.xs4all.home.freekdb.b52reader.gui.MainGuiTest.java
private void testClickInTable(boolean firstStarred, boolean firstRead, boolean spanTable, boolean selectRow, int xMouseEvent) throws InterruptedException, InvocationTargetException { List<Article> testArticles = TestUtilities.getSixTestArticles(); testArticles.get(0).setStarred(firstStarred); testArticles.get(0).setRead(firstRead); MainGui mainGui = new MainGui(mockManyBrowsersPanel); mainGui.setMainCallbacks(mockMainCallbacks); Mockito.when(mockConfiguration.useSpanTable()).thenReturn(spanTable); mainGui.initializeBackgroundBrowsersPanel(mockFrame, mockConfiguration); mainGui.initializeGui(testArticles); waitForGuiTasks();// w ww . j a v a 2 s. co m JTable table = (JTable) findComponent(mockContentPane, JTable.class); assertNotNull(table); if (selectRow) { table.getSelectionModel().setValueIsAdjusting(true); table.getSelectionModel().setSelectionInterval(1, 1); table.getSelectionModel().setValueIsAdjusting(true); table.getSelectionModel().setSelectionInterval(0, 0); } else { table.getSelectionModel().setValueIsAdjusting(true); table.clearSelection(); } MouseEvent mouseEvent = new MouseEvent(table, 123456, new Date().getTime(), 0, xMouseEvent, 10, 1, false); for (MouseListener mouseListener : table.getMouseListeners()) { mouseListener.mouseClicked(mouseEvent); } }
From source file:com.anrisoftware.prefdialog.core.AbstractFieldComponent.java
private void showToolTip() { int id = 0;/* w w w . j a v a 2s.com*/ long when = 0; int modifiers = 0; int x = 0; int y = 0; int clickCount = 0; ToolTipManager.sharedInstance() .mouseMoved(new MouseEvent(component, id, when, modifiers, x, y, clickCount, false)); }
From source file:com.anrisoftware.prefdialog.core.AbstractFieldComponent.java
private void hideToolTip() { int id = 0;//from w ww . j a v a 2s. c o m long when = 0; int modifiers = 0; int x = 0; int y = 0; int clickCount = 0; ToolTipManager.sharedInstance() .mouseExited(new MouseEvent(component, id, when, modifiers, x, y, clickCount, false)); }
From source file:org.pmedv.blackboard.components.BoardEditor.java
/** * Setup the listeners//ww w . j a v a 2 s .c om */ private void initListeners() { addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseDragged(MouseEvent e) { handleMouseDragged(e); } @Override public void mouseMoved(MouseEvent e) { Point p = e.getPoint(); p = BoardUtil.mirrorTransform(p, zoomLayer, e); if (editorMode.equals(EditorMode.CHECK_CONNECTIONS)) { mouseOverLine = EditorUtils.findMouseOverLine(e, BoardEditor.this); } else { mouseOverPin = EditorUtils.findPin(e.getX(), e.getY(), BoardEditor.this); } win.getCustomLabel().setText("x : " + e.getX() + " y : " + e.getY()); if (mouseOverPin != null) { tooltipBuffer.delete(0, tooltipBuffer.length()); tooltipBuffer.append(mouseOverPin.getNum()); if (mouseOverPin.getName() != null) { tooltipBuffer.append(" " + mouseOverPin.getName()); } BoardEditor.this.setToolTipText(tooltipBuffer.toString()); ToolTipManager.sharedInstance() .mouseMoved(new MouseEvent(BoardEditor.this, 0, 0, 0, (int) p.getX(), (int) p.getY(), // X-Y of the mouse for the tool tip 0, false)); } else if (mouseOverLine != null) { tooltipBuffer.delete(0, tooltipBuffer.length()); tooltipBuffer.append("net : " + mouseOverLine.getNetIndex()); BoardEditor.this.setToolTipText(tooltipBuffer.toString()); ToolTipManager.sharedInstance() .mouseMoved(new MouseEvent(BoardEditor.this, 0, 0, 0, (int) p.getX(), (int) p.getY(), // X-Y of the mouse for the tool tip 0, false)); } else { BoardEditor.this.setToolTipText(null); } } }); addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { handleMousePressed(e); } @Override public void mouseReleased(MouseEvent e) { handleMouseReleased(e); } }); addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { Boolean invertMouse = (Boolean) Preferences.values .get("org.pmedv.blackboard.BoardDesignerPerspective.invertMouse"); if (invertMouse) { if (currentZoomIndex - e.getWheelRotation() < zoomLevels.length && currentZoomIndex - e.getWheelRotation() > 0) { currentZoomIndex -= e.getWheelRotation(); } } else { if (currentZoomIndex + e.getWheelRotation() < zoomLevels.length && currentZoomIndex + e.getWheelRotation() > 0) { currentZoomIndex += e.getWheelRotation(); } } JXLayer<?> layer = getZoomLayer(); TransformUI ui = (TransformUI) (Object) layer.getUI(); DefaultTransformModel model = (DefaultTransformModel) ui.getModel(); model.setScale(zoomLevels[currentZoomIndex]); ctx.getBean(ApplicationWindow.class).getZoomCombo().setSelectedItem(zoomLevels[currentZoomIndex]); } }); addMouseMotionListener(AppContext.getContext().getBean(AddTextCommand.class)); }
From source file:com.jcraft.weirdx.DDXWindowImp.java
public void mousePressed(MouseEvent e) { if (threeButton) { if (threeBstate == s) { threeBPressed = e;//w ww.j ava 2s . com threeBstate = sp; return; } if (threeBstate == sp // || threeBstate==sppr ) { threeBPressed = null; threeBstate = spp; e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK))) | InputEvent.BUTTON2_MASK, e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger()); } } procPressed(e); }
From source file:com.jcraft.weirdx.DDXWindowImpSwing.java
public void mouseReleased(MouseEvent e) { if (threeButton) { if (threeBstate == sppr) { threeBPressed = null;/*w ww. j av a2 s. co m*/ threeBstate = s; return; } if (threeBstate == sp) { procPressed(threeBPressed); threeBPressed = null; threeBstate = s; } else if (threeBstate == spp) { threeBPressed = null; threeBstate = sppr; e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK))) | InputEvent.BUTTON2_MASK, e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger()); } } procReleased(e); }
From source file:com.jcraft.weirdx.DDXWindowImp.java
public void mouseReleased(MouseEvent e) { if (threeButton) { if (threeBstate == sppr) { threeBPressed = null;// w w w. ja va 2s .com threeBstate = s; return; } if (threeBstate == sp) { procPressed(threeBPressed); threeBPressed = null; threeBstate = s; } else if (threeBstate == spp) { threeBPressed = null; threeBstate = sppr; e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK))) | InputEvent.BUTTON2_MASK, e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger()); } } try { procReleased(e); } catch (Exception ee) { } }
From source file:com.jcraft.weirdx.DDXWindowImpSwing.java
@SuppressWarnings("unused") public void mouseDragged(MouseEvent e) { if (threeButton) { if (threeBstate != s) { if (threeBstate == sp) { procPressed(threeBPressed); threeBPressed = null;/*from w w w . ja va 2s . com*/ threeBstate = s; } else if (threeBstate == spp) { e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK))) | InputEvent.BUTTON2_MASK, e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger()); } else if (threeBstate == sppr) { return; } } } int x = e.getX() + window.x; int y = e.getY() + window.y; XWindow.sprite.hot.x = x; XWindow.sprite.hot.y = y; int mod = e.getModifiers(); // button 1 -> 16 // button 2 -> 8 // button 3 -> 4 // shift -> 1 // control -> 2 // alt -> 12 ?? int state = 0; int detail = 0; if ((mod & InputEvent.BUTTON1_MASK) != 0) { state |= (1 << 8); detail = 1; } if ((mod & InputEvent.BUTTON2_MASK) != 0) { state |= (1 << 9); detail = 2; } if ((mod & InputEvent.BUTTON3_MASK) != 0) { state |= (1 << 10); detail = 3; } if ((mod & InputEvent.SHIFT_MASK) != 0) state |= 1; if ((mod & InputEvent.CTRL_MASK) != 0) state |= 4; // alt -> state|=8; XWindow.sprite.hot.state = state; px = x; py = y; event.mkMotionNotify(1, window.screen.rootId, /*window.id,*/ XWindow.sprite.win.id, 0, px, py, e.getX(), e.getY(), state, 1); try { if (!XWindow.checkMotion(event, window)) { return; } event.mkMotionNotify(1, window.screen.rootId, /*window.id,*/ XWindow.sprite.win.id, 0, px, py, px - XWindow.sprite.win.x, py - XWindow.sprite.win.y, //e.getX(), //e.getY(), state, 1); if (XWindow.grab != null) XWindow.sendGrabbedEvent(event, false, 1); else XWindow.sendDeviceEvent(XWindow.sprite.win, event, XWindow.grab, null, 1); } catch (Exception ee) { } }