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


Java MouseEvent.getXOnScreen方法代码示例

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


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

示例1: 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

示例2: setLocation

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
/**
 * Calculates the location of the ingame mouse by the position diff and locks
 * the original mouse to the center of the screen.
 *
 * @param mouseLocation
 *          The location of the original mouse.
 */
private void setLocation(final MouseEvent e) {
  if (this.grabMouse && !Game.getScreenManager().isFocusOwner()) {
    return;
  }

  double diffX;
  double diffY;
  if (!this.grabMouse) {
    // get diff relative from last mouse location
    diffX = e.getX() - this.lastLocation.getX();
    diffY = e.getY() - this.lastLocation.getY();
    this.lastLocation = new Point(e.getPoint().x - Game.getScreenManager().getRenderComponent().getCursorOffsetX(), e.getPoint().y - Game.getScreenManager().getRenderComponent().getCursorOffsetY());
  } else {
    // get diff relative from grabbed position
    final double screenCenterX = Game.getScreenManager().getResolution().getWidth() * 0.5;
    final double screenCenterY = Game.getScreenManager().getResolution().getHeight() * 0.5;
    final Point screenLocation = Game.getScreenManager().getScreenLocation();
    final int grabX = (int) (screenLocation.x + screenCenterX);
    final int grabY = (int) (screenLocation.y + screenCenterY);

    // lock original mouse back to the center of the screen
    this.robot.mouseMove(grabX, grabY);

    // calculate diffs and new location for the ingame mouse
    diffX = e.getXOnScreen() - (double) grabX;
    diffY = e.getYOnScreen() - (double) grabY;
  }

  // set new mouse location
  double newX = this.getLocation().getX() + diffX * this.sensitivity;
  double newY = this.getLocation().getY() + diffY * this.sensitivity;
  newX = MathUtilities.clamp(newX, 0, Game.getScreenManager().getResolution().getWidth());
  newY = MathUtilities.clamp(newY, 0, Game.getScreenManager().getResolution().getHeight());

  this.location = new Point2D.Double(newX, newY);
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:44,代码来源:Mouse.java

示例3: mouseDragged

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public void mouseDragged(MouseEvent e) {
	int x = startLoc.x;
	int y = startLoc.y;
	int xOffset = e.getXOnScreen() - x;
	int yOffset = e.getYOnScreen() - y;

	Point newLoc = new Point(lastLoc.x + xOffset, lastLoc.y + yOffset);
	comp.setLocation(newLoc);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:11,代码来源:BubbleWindow.java

示例4: jPanelJanelaMouseReleased

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
/**
 * Captura o nome do componente onde o clique do mouse foi solto
 *
 * @param evt MouseEvent
 */
private void jPanelJanelaMouseReleased(MouseEvent evt) {//GEN-FIRST:event_jPanelJanelaMouseReleased
    mouseIsDown = false;
    DRAG_AND_DROP.setVisible(false);
    Component c = jPanelJanela.findComponentAt(evt.getPoint());
    if (ESPERANDO_ALVO) {
        capturarAlvoGritoDeGuerra(c, evt);
    } else if (PARTIDA.isVezHeroi()) {
        lado = evt.getXOnScreen() < (tela.width / 2) ? Values.LEFT : Values.RIGHT;
        setReleased(c);
    }
    revalidate();
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:18,代码来源:PartidaView.java

示例5: createEvent

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
private MouseEvent createEvent(final MouseEvent original) {
  return new MouseEvent(original.getComponent(), original.getID(), original.getWhen(), original.getModifiers(), (int) this.getLocation().getX(), (int) this.getLocation().getY(), original.getXOnScreen(), original.getYOnScreen(), original.getClickCount(), original.isPopupTrigger(),
      original.getButton());
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:5,代码来源:Mouse.java

示例6: getToolTipText

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public String getToolTipText(MouseEvent event) {
    try {
        // Required to really get the tooltip text:
        putClientProperty("ComputingTooltip", Boolean.TRUE);

        toolTip = null;
        String tipText = null;
        Point p = event.getPoint();

        // Locate the renderer under the event location
        int hitColumnIndex = columnAtPoint(p);
        int hitRowIndex = rowAtPoint(p);

        if ((hitColumnIndex != -1) && (hitRowIndex != -1)) {
            //Outline tbl = (Outline) table;
            if (convertColumnIndexToModel(hitColumnIndex) == 0) {   // tree column index
                // For tree column get the tooltip directly from the renderer data provider
                RenderDataProvider rendata = getRenderDataProvider();
                if (rendata != null) {
                    Object value = getValueAt(hitRowIndex, hitColumnIndex);
                    if (value != null) {
                        String toolT = rendata.getTooltipText(value);
                        if (toolT != null && (toolT = toolT.trim ()).length () > 0) {
                            tipText = toolT;
                        }
                    }
                }
            }

            TableCellRenderer renderer = getCellRenderer(hitRowIndex, hitColumnIndex);
            Component component = prepareRenderer(renderer, hitRowIndex, hitColumnIndex);

            // Now have to see if the component is a JComponent before
            // getting the tip
            if (component instanceof JComponent) {
                // Convert the event to the renderer's coordinate system
                Rectangle cellRect = getCellRect(hitRowIndex, hitColumnIndex, false);
                p.translate(-cellRect.x, -cellRect.y);
                MouseEvent newEvent = new MouseEvent(component, event.getID(),
                                          event.getWhen(), event.getModifiers(),
                                          p.x, p.y,
                                          event.getXOnScreen(),
                                          event.getYOnScreen(),
                                          event.getClickCount(),
                                          event.isPopupTrigger(),
                                          MouseEvent.NOBUTTON);

                if (tipText == null) {
                    tipText = ((JComponent)component).getToolTipText(newEvent);
                }
                toolTip = ((JComponent)component).createToolTip();
            }
        }

        // No tip from the renderer get our own tip
        if (tipText == null)
            tipText = getToolTipText();

        if (tipText != null) {
            tipText = tipText.trim();
            if (tipText.length() > MAX_TOOLTIP_LENGTH &&
                !tipText.regionMatches(false, 0, "<html>", 0, 6)) {   // Do not cut HTML tooltips

                tipText = tipText.substring(0, MAX_TOOLTIP_LENGTH) + "...";
            }
        }
        return tipText;
    } finally {
        putClientProperty("ComputingTooltip", Boolean.FALSE);
    }
    //return super.getToolTipText(event);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:74,代码来源:Outline.java

示例7: mousePressed

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
public void mousePressed(MouseEvent e) {
    dragging = true;
    dragX = e.getXOnScreen();
    dragY = e.getYOnScreen();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:ProfilerPopup.java

示例8: mouseDragged

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
public void mouseDragged(MouseEvent e) {
    if (dragX >= 0 && dragY >= 0) {
        int x = e.getXOnScreen();
        int y = e.getYOnScreen();
        
        int dx = x - dragX;
        int dy = y - dragY;
        
        int newX = window.getX();
        int newY = window.getY();
        int newW = window.getWidth();
        int newH = window.getHeight();
        
        int xx = 0;
        int yy = 0;
        Dimension min = window.getMinimumSize();
        
        if (isResizeLeft(currentResizing)) {
            newX += dx;
            newW -= dx;
            if (newW < min.width) {
                xx = newW - min.width;
                newX += xx;
                newW = min.width;
            }
        } else if (isResizeRight(currentResizing)) {
            newW += dx;
            if (newW < min.width) {
                xx = min.width - newW;
                newW = min.width;
            }
        }
        if (isResizeTop(currentResizing)) {
            newY += dy;
            newH -= dy;
            if (newH < min.height) {
                yy = newH - min.height;
                newY += yy;
                newH = min.height;
            }
        } else if (isResizeBottom(currentResizing)) {
            newH += dy;
            if (newH < min.height) {
                yy = min.height - newH;
                newH = min.height;
            }
        }
        
        window.setBounds(newX, newY, newW, newH);
        content.setSize(newW, newH);
        
        dragX = x + xx;
        dragY = y + yy;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:56,代码来源:ProfilerPopup.java

示例9: formMouseDragged

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
private void formMouseDragged(MouseEvent evt) {                                  
    int x = evt.getXOnScreen();
    int y = evt.getYOnScreen();

    this.setLocation(x - xMouse, y - yMouse);
}
 
开发者ID:PanagiotisDrakatos,项目名称:Weather-Forecast,代码行数:7,代码来源:MainWeatherFrame.java


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