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

The following are Jave code examples for showing how to use getLocationOnScreen() 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: VISNode   File: DragSupport.java   View Source Code Vote up 6 votes
@Override
public void mouseDragged(MouseEvent e) {
    if (dragged != null) {
        Point position = e.getLocationOnScreen();
        position.translate(relativePosition.x, relativePosition.y);
        int diffX = position.x - dragged.getX();
        int diffY = position.y - dragged.getY();
        dragged.setLocation(position.x, position.y);
        try {
            selection.call().stream().
                    filter((it) -> it != dragged).
                    forEach((sel) -> {
                        Point location = sel.getLocation();
                        location.translate(diffX, diffY);
                        sel.setLocation(location);
                    });
        } catch (Exception ex) {
            ExceptionHandler.get().handle(ex);
        }
    }
}
 
Example 2
Project: VISNode   File: JNodeContainer.java   View Source Code Vote up 6 votes
@Override
public void mousePressed(MouseEvent e) {
    if (e.getSource() instanceof JNode) {
        pressedPosition = e.getLocationOnScreen();
        oldSelection = selection.copy();
        JNode node = (JNode) e.getSource();
        // Add new node to selection
        if (e.isControlDown()) {
            if (!selection.contains(node)) {
                selection.add(node);
            }
            node.repaint();
            return;
        }
        // it has only one selection
        if (selection.isEmpty() || selection.size() == 1) {
            for (JNode oldNode : oldSelection) {
                oldNode.repaint();
            }
            selection.set(node);
            node.repaint();
        }
    }

}
 
Example 3
Project: incubator-netbeans   File: InnerPanelSupport.java   View Source Code Vote up 6 votes
@Override
public void mouseExited(MouseEvent e) {
    if (e.getSource() == listClasses && currentPopup != null) {
        // check if hovering above the popup -> do not dismiss.
        // the mouse exits the table, when it crosses the boudary to the
        // tooltip.
        Point screen = e.getLocationOnScreen();
        Rectangle visibleRec = listClasses.getVisibleRect();
        Point pt = visibleRec.getLocation();
        SwingUtilities.convertPointToScreen(pt, listClasses);
        visibleRec.setLocation(pt);
        if (visibleRec.contains(screen)) {
            return;
        }
        
        hidePopup();
    } else if (e.getSource() == this.popupContents) {
        // exit from the popup
        hidePopup();
    }
}
 
Example 4
Project: rapidminer   File: PanningManager.java   View Source Code Vote up 6 votes
@Override
public void eventDispatched(AWTEvent e) {
	if (e instanceof MouseEvent) {
		MouseEvent me = (MouseEvent) e;
		if (!SwingUtilities.isDescendingFrom(me.getComponent(), target)) {
			return;
		}
		if (me.getID() == MouseEvent.MOUSE_RELEASED) {
			// stop when mouse released
			mouseOnScreenPoint = null;
			if (timer.isRunning()) {
				timer.stop();
			}
		} else if (me.getID() == MouseEvent.MOUSE_DRAGGED && me.getComponent() == target) {
			mouseOnScreenPoint = me.getLocationOnScreen();
		} else if (me.getID() == MouseEvent.MOUSE_PRESSED && me.getComponent() == target) {
			mouseOnScreenPoint = me.getLocationOnScreen();
			timer.start();
		}
	}
}
 
Example 5
Project: Motunautr   File: FixedMouseAdapter.java   View Source Code Vote up 6 votes
@Override
public final void mouseReleased(final MouseEvent e) {
	FixedMouseAdapter.this.mouseReleased(e);
	final int b = e.getButton() - 1;
	if (b >= 0 && b < NUM_BUTTONS
			&& startPoints[b] != null
			&& startPoints[b].distanceSq(e.getLocationOnScreen()) <= CLICK_SENSITIVITY_SQ) {
		
		if (e.getWhen() > lastClickTime[b] + MULTI_CLICK_SENSITIVITY_MS
				|| lastClickPos[b] == null || lastClickPos[b].distanceSq(e.getLocationOnScreen()) > CLICK_SENSITIVITY_SQ)
			clickCounts[b] = 1;
		else
			clickCounts[b]++;
		
		lastClickPos[b] = e.getLocationOnScreen();
		lastClickTime[b] = e.getWhen();
		
		final MouseEvent newEvent = new MouseEvent(e.getComponent(), MouseEvent.MOUSE_CLICKED, e.getWhen(), e.getModifiers(), e.getY(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), clickCounts[b], false, b + 1);
		FixedMouseAdapter.this.mouseClicked(newEvent);
		
		startPoints[b] = null;
	}
}
 
Example 6
Project: poe-ladder-tracker-java   File: GUILadderTracker.java   View Source Code Vote up 5 votes
public void mouseDragged(MouseEvent e){
	if(rightMouseButtonPressed){
  Point currCoords = e.getLocationOnScreen();
  windowLadderTracker.setLocation(currCoords.x - mouseDownCompCoords.x, currCoords.y - mouseDownCompCoords.y);
  prefs.put("LadderTrackerLocationX", Integer.toString(currCoords.x - mouseDownCompCoords.x));
  prefs.put("LadderTrackerLocationY", Integer.toString(currCoords.y - mouseDownCompCoords.y));
	}
}
 
Example 7
Project: incubator-netbeans   File: ProfilerTableHovers.java   View Source Code Vote up 5 votes
public void mouseMoved(MouseEvent e) {
            // Do not display popup when a modifier is pressed (can't read all keys)
//            if (e.getModifiers() != 0) return;
            
            currentScreenPoint = e.getLocationOnScreen();
            
            updatePopups(e.getPoint(), false);
        }
 
Example 8
Project: Pogamut3   File: MapController.java   View Source Code Vote up 5 votes
@Override
public void mouseDragged(MouseEvent e) {
    Point current = e.getLocationOnScreen();

    int deltaX = current.x - last.x;
    int deltaY = current.y - last.y;

    changeViewpoint(deltaX, deltaY);

    unregisterListeners();
    //robot.mouseMove(last.x, last.y);
    registerListeners();

    last = current;
}
 
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: YtQueue   File: YtQueueFrame.java   View Source Code Vote up 5 votes
@Override
public void mousePressed(MouseEvent e) {
    pressed = e.getLocationOnScreen();
    YtQueueFrame f = YtQueueFrame.INSTANCE;
    pressed.x -= f.getX();
    pressed.y -= f.getY();
}
 
Example 11
Project: Motunautr   File: FixedMouseAdapter.java   View Source Code Vote up 5 votes
@Override
public final void mousePressed(final MouseEvent e) {
	final int b = e.getButton() - 1;
	if (b >= 0 && b < NUM_BUTTONS)
		startPoints[b] = e.getLocationOnScreen();
	FixedMouseAdapter.this.mousePressed(e);
}
 
Example 12
Project: myqq   File: Login.java   View Source Code Vote up 5 votes
/**
 * 处理窗体的拖拽事件
 * @param e
 */
public void mouseDrag(MouseEvent e)
{
	Point point = e.getLocationOnScreen();
	int offsetX = point.x - lastPoint.x;
	int offsetY = point.y - lastPoint.y;
	Rectangle bounds = this.getBounds();
	bounds.x += offsetX;
	bounds.y += offsetY;
	this.setBounds(bounds);
	lastPoint = point;
}
 
Example 13
Project: rapidminer   File: BubbleWindow.java   View Source Code Vote up 4 votes
@Override
public void mousePressed(MouseEvent e) {
	startLoc = e.getLocationOnScreen();
	lastLoc = comp.getLocation();
}
 
Example 14
Project: hearthstone   File: PartidaView.java   View Source Code Vote up 4 votes
/**
 * Captura o nome do componente onde o mouse foi clicado
 *
 * @param evt MouseEvent
 */
private void jPanelJanelaMousePressed(MouseEvent evt) {//GEN-FIRST:event_jPanelJanelaMousePressed
    CLICOU = evt.getLocationOnScreen();
    setPressed(jPanelJanela.findComponentAt(evt.getPoint()));
    revalidate();
}
 
Example 15
Project: Pogamut3   File: MapController.java   View Source Code Vote up 4 votes
@Override
public void mouseReleased(MouseEvent e) {
    updateMode(e);
    last = e.getLocationOnScreen();
}
 
Example 16
Project: Moenagade   File: BloxsEditor.java   View Source Code Vote up 4 votes
@Override
public void mouseDragged(MouseEvent me) {
    // convert point in case we got triggered by a libraryPanel
    Point clickPoint = me.getPoint();
    //System.out.println("me.source: "+me.getSource());
    
    if(me.getSource() instanceof LibraryPanel)
    {
        clickPoint = new java.awt.Point(me.getLocationOnScreen());
        SwingUtilities.convertPointFromScreen(clickPoint, this);
        /*
        // get the selected item if there is any
        if(selected==null)
        {
            if(Library.getInstance().getSelected()!=null)
            {
                selected = Library.getInstance().getSelected().clone();
                selectedDelta = (Dimension) Library.getInstance().getSelectedDelta().clone();
                elements.add(selected);
            }
        }/**/
    }
    
    if(((me.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0))
    {
        if(selected!=null)
        {
            // disconnect it!
            selected.setParent(null);
            
            // move 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)));
            }
            for (int i = 0; i < elements.size(); i++) {
                Element get = elements.get(i);
                get.cleanDockStatus();
                // check if docking is possible
                Element dock = get.canDock(selected);                      
            }
            //System.out.println("Dock: "+dock);
        }

        repaint();
    }
}
 
Example 17
Project: Moenagade   File: BloxsEditor.java   View Source Code Vote up 4 votes
@Override
public void mousePressed(MouseEvent me) {
    
    // convert point in case we got triggered by a libraryPanel
    Point clickPoint = me.getPoint();
    //System.out.println("me.source: "+me.getSource());
    if(me.getSource() instanceof LibraryPanel)
    {
        // close any list if open
        if(list!=null && ((List)list).isOpen())
        {
            ((List)list).toggle();
        }
        // null out the reference
        list=null;
        
        clickPoint = new java.awt.Point(me.getLocationOnScreen());
        SwingUtilities.convertPointFromScreen(clickPoint, this);
        // get the selected item if there is any
        //if(selected==null)
        {
            if(Library.getInstance().getSelected()!=null &&
               ((Library.getInstance().getSelected().isElementary() &&
               !hasElementOfType(Library.getInstance().getSelected().getClassname())) ||
               (!Library.getInstance().getSelected().isElementary() 
                    || (Library.getInstance().getSelected().getClassname().equals("AttributeDefinition"))
                    || (Library.getInstance().getSelected().getClassname().equals("MethodDefinition"))
                )))
            {
                pushUndo();
                selected = Library.getInstance().getSelected().clone();
                selectedDelta = (Dimension) Library.getInstance().getSelectedDelta().clone();
                addElement(selected);
                selected.setParent(null);
                return;
            }
            
            // no item selected in library --> stop here
            return;
        }
    }
    
    // first let's see if there is not an opened list
    if(list!=null)
    {
        // execute the event on the opened list
        mouseOnElement(list,me);
    }
    // if not, loop through all elements contained inside the editor
    else for (int i = elements.size()-1; i >=0 && selected==null; i--) {
        Element element = elements.get(i);
        // execute the event on the actual element,
        // break the loop if requested
        if(mouseOnElement(element,me)) break;
    }
    
    // NOT NEEDED HERE
    //somethingChanged();
}
 
Example 18
Project: myqq   File: Login.java   View Source Code Vote up 4 votes
/**
 * 处理窗体的鼠标按下事件
 * @param e
 */
public void mousePress(MouseEvent e)
{
	lastPoint = e.getLocationOnScreen();
}
 
Example 19
Project: incubator-netbeans   File: ProfilerTableHovers.java   View Source Code Vote up 3 votes
public void mouseDragged(MouseEvent e) {
//            if (e.getModifiers() != 0) return;
            
            currentScreenPoint = e.getLocationOnScreen();
            
            updatePopups(e.getPoint(), false);
        }
 
Example 20
Project: hearthstone   File: PartidaView.java   View Source Code Vote up 2 votes
/**
 * Evento gerado ao arrastar o mouse. Atualiza a variável soltou (Point)
 * para desenhar a seta com o arrasto do mouse
 *
 * @param evt MouseEvent
 */
private void jPanelJanelaMouseDragged(MouseEvent evt) {//GEN-FIRST:event_jPanelJanelaMouseDragged
    disposeAllPopUps();
    SOLTOU = evt.getLocationOnScreen();
    mouseIsDown = true;
}