Java Code Examples for java.awt.event.MouseEvent.getSource()

The following are Jave code examples for showing how to use getSource() of the java.awt.event.MouseEvent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: geomapapp   File: ShipData.java   View Source Code Vote up 6 votes
public void mouseMoved(MouseEvent evt) {
		if(map==null)return;
		if( !(evt.getSource() instanceof XYGraph) ) {
			return;
		}
		XYGraph graph = (XYGraph)evt.getSource();
		float x0 = (float)graph.getXAt( evt.getPoint() );
		for( int i=currentRange[0]+1 ; i<currentRange[1] ; i++) {
			if( x[i]>x0 ) {
				if( i!=0 && x0-x[i-1]<x[i]-x0) i--;
				Point2D p = map.getProjection().getMapXY(
						new Point2D.Double( lon[i], lat[i] ));
				drawCurrentPoint();
				currentPoint = (Point2D.Double)p;

//				
				map.setLonLat( lon[i], lat[i] );
				map.setAlternateZValue(Float.NaN);
				map.setAlternateUnits(units[0]);
//				***** GMA 1.6.2

				drawCurrentPoint();
				return;
			}
		}
	}
 
Example 2
Project: incubator-netbeans   File: CheckNodeListener.java   View Source Code Vote up 6 votes
@Override
public void mousePressed(MouseEvent event) {
    JTree tree = (JTree) event.getSource();
    int x = event.getX();
    int y = event.getY();

    int row = tree.getRowForLocation(x, y);
    TreePath path = tree.getPathForRow(row);

    // if path exists and mouse is clicked exactly once
    if (path == null) {
        return;
    }
    CheckNode node = (CheckNode) path.getLastPathComponent();

    if ( !SwingUtilities.isRightMouseButton(event)) {
        return;
    }
    Object o = node.getUserObject();

}
 
Example 3
Project: parabuild-ci   File: TableSorter.java   View Source Code Vote up 6 votes
public void mouseClicked(MouseEvent e) {

            JTableHeader     h           = (JTableHeader) e.getSource();
            TableColumnModel columnModel = h.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX());
            int column = columnModel.getColumn(viewColumn).getModelIndex();

            if (column != -1) {
                int status = getSortingStatus(column);

                if (!e.isControlDown()) {
                    cancelSorting();
                }

                // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or
                // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed.
                status = status + (e.isShiftDown() ? -1
                                                   : 1);
                status = (status + 4) % 3 - 1;    // signed mod, returning {-1, 0, 1}

                setSortingStatus(column, status);
            }
        }
 
Example 4
Project: WordnetLoom   File: AbstractPerspective.java   View Source Code Vote up 6 votes
/**
 * dwuklik myszką w zakładke powoduje zwiniecie
 *
 * @param event
 */
@Override
public void mouseClicked(MouseEvent event) {
    if (event.getClickCount() != 2) {
        return; // czy to byl dwuklik
    }
    // przejście po wszystkich splitterach
    for (MSplitPane splitter : splitters) {
        // czy funkcja jest wspierana
        if (!splitter.isOneTouchExpandable()) {
            continue;
        }
        int count = splitter.getComponentCount();
        // przejście po wszystkich komponentach należących do splitera
        for (int i = 0; i < count; i++) {
            // jeśli sygnał pochodzi od komponentu
            // to zwinięcie widoku
            if (splitter.getComponent(i) == event.getSource()) {
                splitter.collapse(i);
                return;
            }
        }
    }
}
 
Example 5
Project: WordnetLoom   File: ViwnGraphViewModalGraphMouse.java   View Source Code Vote up 5 votes
@Override
public void mousePressed(MouseEvent e) {
    // TRANSLATING PART
    VisualizationViewer<ViwnNode, ViwnEdge> vv = (VisualizationViewer<ViwnNode, ViwnEdge>) e.getSource();
    boolean accepted = checkModifiers(e);
    down = e.getPoint();
    if (accepted) {
        vv.setCursor(cursor);
    }
}
 
Example 6
Project: incubator-netbeans   File: SearchButton.java   View Source Code Vote up 5 votes
@Override
public void mouseExited(MouseEvent evt) {
    Object src = evt.getSource();
    if (src instanceof AbstractButton) {
        AbstractButton button = (AbstractButton) evt.getSource();
        removeButtonContentAreaAndBorder(button);
    }
}
 
Example 7
Project: Tarski   File: EditorMouseMotionListener.java   View Source Code Vote up 5 votes
@Override
public void mouseDragged(final MouseEvent e) {
  if (e.getSource() == StaticEditorManager.graphComponent.getGraphControl()) {
    StaticListenerManager.newCenterX =
        (int) (StaticListenerManager.oldCenterX + (e.getX() - StaticListenerManager.oldMouseX));
    StaticListenerManager.newCenterY =
        (int) (StaticListenerManager.oldCenterY + (e.getY() - StaticListenerManager.oldMouseY));
    if (SwingUtilities.isLeftMouseButton(e)) {
      StaticListenerManager.tweakCell(e);
      StaticListenerManager.isDragStart = true;
    }
  }
}
 
Example 8
Project: incubator-netbeans   File: ButtonPopupSwitcher.java   View Source Code Vote up 5 votes
private void changeSelection( MouseEvent e ) {
    Point p = e.getPoint();
    // It may have occured on the button that invoked the tabtable
    if (e.getSource() != this) {
        p = SwingUtilities.convertPoint((Component) e.getSource(), p, pTable);
    }
    if (pTable.contains(p)) {
        int row = pTable.rowAtPoint(p);
        int col = pTable.columnAtPoint(p);
        pTable.changeSelection(row, col, false, false);
    } else {
        pTable.clearSelection();
    }
}
 
Example 9
Project: Moenagade   File: BloxsEditor.java   View Source Code Vote up 5 votes
@Override
public void mouseReleased(MouseEvent me) {
    // convert point in case we got triggered by a libraryPanel
    Point clickPoint = me.getPoint();
    if(me.getSource() instanceof LibraryPanel)
    {
        clickPoint = new java.awt.Point(me.getLocationOnScreen());
        SwingUtilities.convertPointFromScreen(clickPoint, this);
    }
    
    // only act if we had an element 
    if(selected!=null)
    {
        // repostion element
        selected.setOffset(new Point(clickPoint.x-selectedDelta.width,
                                     clickPoint.y-selectedDelta.height));
        if(selected.isElementary())
        {
            selected.setOffset(new Point((clickPoint.x-selectedDelta.width) -((clickPoint.x-selectedDelta.width) % 10),
                                         (clickPoint.y-selectedDelta.height)-((clickPoint.y-selectedDelta.height)% 10)));
        }
        
        if(selected.getType()!=Type.PARAMETERS &&
                   selected.getType()!=Type.LIST &&
                   selected.getType()!=Type.ITEM)
        {
            putBack(selected); 
        }
        
        // something changed
        somethingChanged();
    }   
    selected=null;
    
    repaint();
}
 
Example 10
Project: JavaGraph   File: LibrariesTable.java   View Source Code Vote up 5 votes
@Override
public void mouseExited(MouseEvent e) {
    JTable table = (JTable) e.getSource();
    table.repaint(table.getCellRect(this.row, this.col, false));
    this.row = -1;
    this.col = -1;
}
 
Example 11
Project: incubator-netbeans   File: ButtonPopupSwitcherTestHid.java   View Source Code Vote up 5 votes
private void pButAction(MouseEvent e) {
    // create popup with our SwitcherTable
    JComponent c = (JComponent) e.getSource();
    Point p = new Point(c.getWidth(), c.getHeight());
    SwingUtilities.convertPointToScreen(p, c);
    if (!ButtonPopupSwitcher.isShown()) {
        ButtonPopupSwitcher.showPopup( c, displayer, p.x, p.y);
    }
}
 
Example 12
Project: incubator-netbeans   File: ButtonPopupSwitcher.java   View Source Code Vote up 5 votes
private void changeSelection( MouseEvent e ) {
    Point p = e.getPoint();
    // It may have occured on the button that invoked the tabtable
    if (e.getSource() != this) {
        p = SwingUtilities.convertPoint((Component) e.getSource(), p, pTable);
    }
    if (pTable.contains(p)) {
        int row = pTable.rowAtPoint(p);
        int col = pTable.columnAtPoint(p);
        pTable.changeSelection(row, col, false, false);
    } else {
        pTable.clearSelection();
    }
}
 
Example 13
Project: incubator-netbeans   File: PSheet.java   View Source Code Vote up 5 votes
private void updateSheetTableSelection(MouseEvent e) {
    Component comp = (Component) e.getSource();

    if (comp instanceof SheetTable) {
        SheetTable table = (SheetTable) comp;
        table.changeSelection(table.rowAtPoint(e.getPoint()), 0, false, false);
    }
}
 
Example 14
Project: jdk8u-jdk   File: WindowsMenuUI.java   View Source Code Vote up 5 votes
public void mouseExited(MouseEvent evt) {
    super.mouseExited(evt);

    JMenu menu = (JMenu)evt.getSource();
    ButtonModel model = menu.getModel();
    if (menu.isRolloverEnabled()) {
        model.setRollover(false);
        menuItem.repaint();
    }
}
 
Example 15
Project: incubator-netbeans   File: DataViewUI.java   View Source Code Vote up 5 votes
@Override
public void mouseEntered(MouseEvent evt) {
    Object src = evt.getSource();

    if (src instanceof AbstractButton) {
        AbstractButton button = (AbstractButton) evt.getSource();
        if (button.isEnabled()) {
            button.setContentAreaFilled(true);
            button.setBorderPainted(true);
        }
    }
}
 
Example 16
Project: WordnetLoom   File: ViwnGraphViewModalGraphMouse.java   View Source Code Vote up 5 votes
public void mouseEntered(MouseEvent e) {
    JComponent c = (JComponent) e.getSource();
    ViWordNetService s = (ViWordNetService) vgvui.getWorkbench().getService(Service.class.getName());
    if (s != null && !s.isMakeRelationModeOn()) {
        c.setCursor(cursor);
    }
}
 
Example 17
Project: JITRAX   File: TablePanelListener.java   View Source Code Vote up 4 votes
/**
 * Makes a table selected if the user clicks it.
 */
public void mouseClicked(MouseEvent e) {
		TablePanel targetTablePanel = ((TablePanel) e.getSource());
		updateSelectedTable(targetTablePanel);
}
 
Example 18
Project: Star-Ride--RiverRaid   File: Creditos.java   View Source Code Vote up 4 votes
@Override
public void mouseExited(MouseEvent e) {
    if(e.getSource() == volverMenu){
        volverMenu.setIcon(AsignLabelDimension(new ImageIcon(pathBaseLabel+"Flecha-1.png"), volverMenu));
    }
}
 
Example 19
Project: featurea   File: PreferencesPanel.java   View Source Code Vote up 4 votes
@Override
public void mouseExited(MouseEvent e) {
    JPanel panel = (JPanel) e.getSource();
    // set the border back
    panel.setBorder(this.originalBorder);
}
 
Example 20
Project: FreeCol   File: CanvasMapEditorMouseListener.java   View Source Code Vote up 4 votes
/**
 * {@inheritDoc}
 */
@Override
public void mouseReleased(MouseEvent e) {
    if (getMap() == null
        || e.getButton() == MouseEvent.BUTTON1
        || getGUI().getFocus() == null) return;
    final JComponent component = (JComponent)e.getSource();
    final MapEditorController controller
        = getFreeColClient().getMapEditorController();
    final boolean isTransformActive = controller.getMapTransform() != null;

    endPoint = e.getPoint();
    if (startPoint == null) startPoint = endPoint;
    drawBox(component, startPoint, endPoint);
    Tile start = canvas.convertToMapTile(startPoint.x, startPoint.y);
    Tile end = (startPoint == endPoint) ? start
        : canvas.convertToMapTile(endPoint.x, endPoint.y);

    // edit 2 more conditions in if statement.  we need to
    // check for coordinator of X and Y if (x,y) outside of
    // map then dont focus to that else setfocus to that
    // position no option selected, just center map
    if (!isTransformActive && end.getX() >= 0 && end.getY() >= 0) {
        getGUI().setFocus(end);
        return;
    }

    // find the area to transform
    int min_x, max_x, min_y, max_y;
    if (start.getX() < end.getX()) {
        min_x = start.getX();
        max_x = end.getX();
    } else {
        min_x = end.getX();
        max_x = start.getX();
    }
    if (start.getY() < end.getY()) {
        min_y = start.getY();
        max_y = end.getY();
    } else {
        min_y = end.getY();
        max_y = start.getY();
    }

    // apply transformation to all tiles in the area
    Tile t = null;
    for (int x = min_x; x <= max_x; x++) {
        for (int y = min_y; y <= max_y; y++) {
            t = getMap().getTile(x, y);
            if (t != null) {
                controller.transform(t);
            }
        }
    }
    if (controller.getMapTransform() instanceof TileTypeTransform) {
        for (int x = min_x - 2; x <= max_x + 2; x++) {
            for (int y = min_y - 2; y <= max_y + 2; y++) {
                t = getMap().getTile(x, y);
                if (t != null && t.getType().isWater()) {
                    TerrainGenerator.encodeStyle(t);
                }
            }
        }
    }
    getGUI().refresh();
    canvas.requestFocus();
}