本文整理汇总了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);
}
}
}
示例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();
}
}
}
示例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();
}
}
示例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();
}
}
}
示例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;
}
}
示例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));
}
}
示例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);
}
示例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;
}
示例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();
}
示例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();
}
示例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);
}
示例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;
}
示例13: mousePressed
import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public void mousePressed(MouseEvent e) {
startLoc = e.getLocationOnScreen();
lastLoc = comp.getLocation();
}
示例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();
}
示例15: mouseReleased
import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public void mouseReleased(MouseEvent e) {
updateMode(e);
last = e.getLocationOnScreen();
}