当前位置: 首页>>代码示例>>Java>>正文


Java MouseEvent.getLocationOnScreen方法代码示例

本文整理汇总了Java中java.awt.event.MouseEvent.getLocationOnScreen方法的典型用法代码示例。如果您正苦于以下问题:Java MouseEvent.getLocationOnScreen方法的具体用法?Java MouseEvent.getLocationOnScreen怎么用?Java MouseEvent.getLocationOnScreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.event.MouseEvent的用法示例。


在下文中一共展示了MouseEvent.getLocationOnScreen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mouseDragged

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@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);
        }
    }
}
 
开发者ID:VISNode,项目名称:VISNode,代码行数:22,代码来源:DragSupport.java

示例2: mousePressed

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@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();
        }
    }

}
 
开发者ID:VISNode,项目名称:VISNode,代码行数:26,代码来源:JNodeContainer.java

示例3: mouseExited

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@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();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:InnerPanelSupport.java

示例4: eventDispatched

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@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();
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:22,代码来源:PanningManager.java

示例5: mouseReleased

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@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;
	}
}
 
开发者ID:Njol,项目名称:Motunautr,代码行数:24,代码来源:FixedMouseAdapter.java

示例6: mouseDragged

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
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));
	}
}
 
开发者ID:jkjoschua,项目名称:poe-ladder-tracker-java,代码行数:9,代码来源:GUILadderTracker.java

示例7: mouseMoved

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
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);
        }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ProfilerTableHovers.java

示例8: mouseDragged

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@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;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:16,代码来源:MapController.java

示例9: mouseReleased

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@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();
}
 
开发者ID:fesch,项目名称:Moenagade,代码行数:37,代码来源:BloxsEditor.java

示例10: mousePressed

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public void mousePressed(MouseEvent e) {
    pressed = e.getLocationOnScreen();
    YtQueueFrame f = YtQueueFrame.INSTANCE;
    pressed.x -= f.getX();
    pressed.y -= f.getY();
}
 
开发者ID:RanolP,项目名称:YtQueue,代码行数:8,代码来源:YtQueueFrame.java

示例11: mousePressed

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@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);
}
 
开发者ID:Njol,项目名称:Motunautr,代码行数:8,代码来源:FixedMouseAdapter.java

示例12: mouseDrag

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
/**
 * 处理窗体的拖拽事件
 * @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;
}
 
开发者ID:sxei,项目名称:myqq,代码行数:16,代码来源:Login.java

示例13: mousePressed

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public void mousePressed(MouseEvent e) {
	startLoc = e.getLocationOnScreen();
	lastLoc = comp.getLocation();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:6,代码来源:BubbleWindow.java

示例14: jPanelJanelaMousePressed

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:11,代码来源:PartidaView.java

示例15: mouseReleased

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public void mouseReleased(MouseEvent e) {
    updateMode(e);
    last = e.getLocationOnScreen();
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:6,代码来源:MapController.java


注:本文中的java.awt.event.MouseEvent.getLocationOnScreen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。