List of usage examples for java.awt.event MouseEvent getPoint
public Point getPoint()
From source file:lu.fisch.unimozer.Diagram.java
@Override public void mouseDragged(MouseEvent e) { if (mousePressed == true && isEnabled()) { if (mode == MODE_EXTENDS) { extendsDragPoint = e.getPoint(); repaint();//from ww w .j a v a2s .c o m } else { boolean doRepaint = false; if (mouseClass != null) { mouseClass.setPosition( new Point(e.getX() - mouseRelativePoint.x, e.getY() - mouseRelativePoint.y)); doRepaint = true; } else if (mousePackage != null) { for (MyClass myClass : classes.values()) { if (myClass.getPackagename().equals(mousePackage.getName())) { myClass.setPosition(new Point(myClass.getPosition().x + e.getX() - mouseRelativePoint.x, myClass.getPosition().y + e.getY() - mouseRelativePoint.y)); } doRepaint = true; } mouseRelativePoint = e.getPoint(); } if (doRepaint) repaint(); } } }
From source file:v800_trainer.JCicloTronic.java
private void DatentabelleMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_DatentabelleMouseClicked // Add your handling code here: if (evt.getButton() == MouseEvent.BUTTON3 && evt.getButton() != MouseEvent.BUTTON1) { int dummy = Datentabelle.rowAtPoint(evt.getPoint()); int selection[] = Datentabelle.getSelectedRows(); boolean isselected = false; for (int i = 0; i < selection.length; i++) { if (dummy == selection[i]) { isselected = true;/* w w w .j av a 2 s .co m*/ } } ; Datentabelle.clearSelection(); if (!isselected) { Datentabelle.addRowSelectionInterval(dummy, dummy); } for (int i = 0; i < selection.length; i++) { if (dummy != selection[i]) { Datentabelle.addRowSelectionInterval(selection[i], selection[i]); } } } SelectionChanged = true; Update = false; Datenliste_Monat.setEnabled(false); Datenliste_Monat.setSelectedIndex(0); Datenliste_Jahr.setSelectedIndex(0); Datenliste_Zeitabschnitt.setSelectedIndex(0); Datenliste_TourTyp.setSelectedIndex(0); Update = true; jLabel69_Selektiert.setText(Datentabelle.getSelectedRowCount() + " / " + Datentabelle.getRowCount()); if (evt.getClickCount() == 2) { Hauptfenster.setSelectedIndex(1); } }
From source file:lu.fisch.unimozer.Diagram.java
@Override public void mouseReleased(MouseEvent e) { if (isEnabled() && e.getButton() == MouseEvent.BUTTON1) { if (mode == MODE_EXTENDS) { extendsTo = getMouseClass(e.getPoint()); if ((extendsFrom != null) && (extendsTo != null) && (extendsFrom != extendsTo)) { // %TODO% extendsFrom.addExtends(extendsTo.getShortName()); repaint();//from ww w .ja va 2 s.c o m } // change the mode back to SELECT setMode(MODE_SELECT); // update the bouttons in the mainform frame.updateMode(); // free pointers extendsDragPoint = null; extendsFrom = null; extendsTo = null; deselectAll(); } else { // load the clickled class (if clicked!) if (mousePressed == true) loadClickedClass(e); mousePressed = false; } } }
From source file:lu.fisch.unimozer.Diagram.java
@Override public void mouseMoved(MouseEvent e) { if (isEnabled()) { // reset/*from w w w . j a va 2 s .c o m*/ commentString = null; commentPoint = null; // get position mousePoint = e.getPoint(); MyClass mouseAtCursor = getMouseClassNoSelect(mousePoint); if (mouseAtCursor != null) { Element ele = mouseAtCursor.getHover(mousePoint); if (ele != null) { if (ele.getJavaDoc() != null) { commentString = ele.getJavaDoc(); commentPoint = mousePoint; } } } repaint(); } }
From source file:lu.fisch.unimozer.Diagram.java
@Override public void mousePressed(MouseEvent e) { if (isEnabled() && e.getButton() == MouseEvent.BUTTON1) { if (mode == MODE_EXTENDS) { // get the clicked point mousePoint = e.getPoint(); mousePressed = true;/*from w ww . j ava 2s . c o m*/ // get clicked class extendsFrom = getMouseClass(mousePoint); extendsDragPoint = e.getPoint(); if (extendsFrom == null) { setMode(MODE_SELECT); frame.updateMode(); } } else { if (e.getButton() == MouseEvent.BUTTON1) mousePressed = true; // get the clicked point mousePoint = e.getPoint(); // get clicked package getMousePackage(mousePoint); // get clicked class MyClass clickClass = getMouseClass(mousePoint); if (clickClass != null) mouseRelativePoint = clickClass.getRelative(mousePoint); else if (mousePackage != null) { mouseRelativePoint = mousePoint; } // load the clicked class loadClickedClass(e); } } }
From source file:erigo.ctstream.CTstream.java
/** * /*from www . ja v a 2s . c om*/ * mouseDragged * * Implement the mouseDragged method defined by interface MouseMotionListener. * * This method implements the "guts" of our homemade window manager; this method * handles moving and resizing the frame. * * Why have we implemented our own window manager? Since translucent panels * can only be contained within undecorated Frames (see comments in the top * header above) and since undecorated Frames don't support moving/resizing, * we implement our own basic "window manager" by catching mouse move and drag * events. * * @author John P. Wilson * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent) */ @Override public void mouseDragged(MouseEvent mouseEventI) { // System.err.println("mouseDragged: " + mouseEventI.getX() + "," + mouseEventI.getY()); // Keep the screen capture area to at least a minimum width and height boolean bDontMakeThinner = false; boolean bDontMakeShorter = false; if (capturePanel.getHeight() < 20) { bDontMakeShorter = true; } if (capturePanel.getWidth() < 20) { bDontMakeThinner = true; } Point currentPoint = mouseEventI.getLocationOnScreen(); int currentPosX = currentPoint.x; int currentPosY = currentPoint.y; int deltaX = 0; int deltaY = 0; if ((mouseCommandMode != NO_COMMAND) && (mouseStartingPoint != null)) { deltaX = currentPosX - mouseStartingPoint.x; deltaY = currentPosY - mouseStartingPoint.y; } int oldFrameWidth = guiFrame.getBounds().width; int oldFrameHeight = guiFrame.getBounds().height; if (mouseCommandMode == MOVE_FRAME) { Point updatedGUIFrameLoc = new Point(frameStartingBounds.x + deltaX, frameStartingBounds.y + deltaY); guiFrame.setLocation(updatedGUIFrameLoc); } else if (mouseCommandMode == RESIZE_FRAME_NW) { int newFrameWidth = frameStartingBounds.width - deltaX; int newFrameHeight = frameStartingBounds.height - deltaY; if ((bDontMakeThinner && (newFrameWidth < oldFrameWidth)) || (bDontMakeShorter && (newFrameHeight < oldFrameHeight))) { return; } Rectangle updatedGUIFrameBounds = new Rectangle(frameStartingBounds.x + deltaX, frameStartingBounds.y + deltaY, newFrameWidth, newFrameHeight); guiFrame.setBounds(updatedGUIFrameBounds); } else if (mouseCommandMode == RESIZE_FRAME_N) { int newFrameWidth = frameStartingBounds.width; int newFrameHeight = frameStartingBounds.height - deltaY; if (bDontMakeShorter && (newFrameHeight < oldFrameHeight)) { return; } Rectangle updatedGUIFrameBounds = new Rectangle(frameStartingBounds.x, frameStartingBounds.y + deltaY, newFrameWidth, newFrameHeight); guiFrame.setBounds(updatedGUIFrameBounds); } else if (mouseCommandMode == RESIZE_FRAME_NE) { int newFrameWidth = frameStartingBounds.width + deltaX; int newFrameHeight = frameStartingBounds.height - deltaY; if ((bDontMakeThinner && (newFrameWidth < oldFrameWidth)) || (bDontMakeShorter && (newFrameHeight < oldFrameHeight))) { return; } Rectangle updatedGUIFrameBounds = new Rectangle(frameStartingBounds.x, frameStartingBounds.y + deltaY, newFrameWidth, newFrameHeight); guiFrame.setBounds(updatedGUIFrameBounds); } else if (mouseCommandMode == RESIZE_FRAME_E) { int newFrameWidth = frameStartingBounds.width + deltaX; int newFrameHeight = frameStartingBounds.height; if (bDontMakeThinner && (newFrameWidth < oldFrameWidth)) { return; } Rectangle updatedGUIFrameBounds = new Rectangle(frameStartingBounds.x, frameStartingBounds.y, newFrameWidth, newFrameHeight); guiFrame.setBounds(updatedGUIFrameBounds); } else if (mouseCommandMode == RESIZE_FRAME_SE) { int newFrameWidth = frameStartingBounds.width + deltaX; int newFrameHeight = frameStartingBounds.height + deltaY; if ((bDontMakeThinner && (newFrameWidth < oldFrameWidth)) || (bDontMakeShorter && (newFrameHeight < oldFrameHeight))) { return; } Rectangle updatedGUIFrameBounds = new Rectangle(frameStartingBounds.x, frameStartingBounds.y, newFrameWidth, newFrameHeight); guiFrame.setBounds(updatedGUIFrameBounds); } else if (mouseCommandMode == RESIZE_FRAME_S) { int newFrameWidth = frameStartingBounds.width; int newFrameHeight = frameStartingBounds.height + deltaY; if (bDontMakeShorter && (newFrameHeight < oldFrameHeight)) { return; } Rectangle updatedGUIFrameBounds = new Rectangle(frameStartingBounds.x, frameStartingBounds.y, newFrameWidth, newFrameHeight); guiFrame.setBounds(updatedGUIFrameBounds); } else if (mouseCommandMode == RESIZE_FRAME_SW) { int newFrameWidth = frameStartingBounds.width - deltaX; int newFrameHeight = frameStartingBounds.height + deltaY; if ((bDontMakeThinner && (newFrameWidth < oldFrameWidth)) || (bDontMakeShorter && (newFrameHeight < oldFrameHeight))) { return; } Rectangle updatedGUIFrameBounds = new Rectangle(frameStartingBounds.x + deltaX, frameStartingBounds.y, newFrameWidth, newFrameHeight); guiFrame.setBounds(updatedGUIFrameBounds); } else if (mouseCommandMode == RESIZE_FRAME_W) { int newFrameWidth = frameStartingBounds.width - deltaX; int newFrameHeight = frameStartingBounds.height; if (bDontMakeThinner && (newFrameWidth < oldFrameWidth)) { return; } Rectangle updatedGUIFrameBounds = new Rectangle(frameStartingBounds.x + deltaX, frameStartingBounds.y, newFrameWidth, newFrameHeight); guiFrame.setBounds(updatedGUIFrameBounds); } else { // See if we need to go into a particular command mode mouseStartingPoint = null; frameStartingBounds = null; mouseCommandMode = getGUIFrameCommandMode(mouseEventI.getPoint()); if (mouseCommandMode != NO_COMMAND) { mouseStartingPoint = mouseEventI.getLocationOnScreen(); frameStartingBounds = guiFrame.getBounds(); } } }
From source file:com.peterbochs.PeterBochsDebugger.java
private void jHexTable1MouseClicked(MouseEvent evt) { if (SwingUtilities.isRightMouseButton(evt)) { // select Point p = evt.getPoint(); int rowNumber = jHexTable1.rowAtPoint(p); int columnNumber = jHexTable1.columnAtPoint(p); ListSelectionModel model = jHexTable1.getSelectionModel(); model.setSelectionInterval(rowNumber, rowNumber); jHexTable1.getColumnModel().getSelectionModel().setSelectionInterval(columnNumber, columnNumber); // end select getJHexTablePopupMenu().show(evt.getComponent(), evt.getX(), evt.getY()); }/*w w w . j a v a 2 s. c om*/ }
From source file:com.peterbochs.PeterBochsDebugger.java
private void jELFTableMouseClicked(MouseEvent evt) { if (SwingUtilities.isRightMouseButton(evt)) { // select Point p = evt.getPoint(); int rowNumber = elfTable.rowAtPoint(p); int columnNumber = elfTable.columnAtPoint(p); ListSelectionModel model = elfTable.getSelectionModel(); model.setSelectionInterval(rowNumber, rowNumber); elfTable.getColumnModel().getSelectionModel().setSelectionInterval(columnNumber, columnNumber); // end select getJELFTablePopupMenu().show(evt.getComponent(), evt.getX(), evt.getY()); }//from www . j a v a2 s.c om }
From source file:com.peterbochs.PeterBochsDebugger.java
private void breakpointTableMouseClicked(MouseEvent evt) { if (SwingUtilities.isRightMouseButton(evt)) { // select Point p = evt.getPoint(); int rowNumber = breakpointTable.rowAtPoint(p); int columnNumber = breakpointTable.columnAtPoint(p); ListSelectionModel model = breakpointTable.getSelectionModel(); model.setSelectionInterval(rowNumber, rowNumber); breakpointTable.getColumnModel().getSelectionModel().setSelectionInterval(columnNumber, columnNumber); // end select getJBreakpointPopupMenu().show(evt.getComponent(), evt.getX(), evt.getY()); }/* w ww. ja v a2 s .c o m*/ }
From source file:com.peterbochs.PeterBochsDebugger.java
private void jSearchMemoryTableMouseClicked(MouseEvent evt) { if (SwingUtilities.isRightMouseButton(evt)) { // select Point p = evt.getPoint(); int rowNumber = jSearchMemoryTable.rowAtPoint(p); int columnNumber = jSearchMemoryTable.columnAtPoint(p); ListSelectionModel model = jSearchMemoryTable.getSelectionModel(); model.setSelectionInterval(rowNumber, rowNumber); jSearchMemoryTable.getColumnModel().getSelectionModel().setSelectionInterval(columnNumber, columnNumber);//from w w w. j a v a2 s . c o m // end select getJSearchMemoryTablePopupMenu().show(evt.getComponent(), evt.getX(), evt.getY()); } }