當前位置: 首頁>>代碼示例>>Java>>正文


Java MouseInfo.getPointerInfo方法代碼示例

本文整理匯總了Java中java.awt.MouseInfo.getPointerInfo方法的典型用法代碼示例。如果您正苦於以下問題:Java MouseInfo.getPointerInfo方法的具體用法?Java MouseInfo.getPointerInfo怎麽用?Java MouseInfo.getPointerInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.MouseInfo的用法示例。


在下文中一共展示了MouseInfo.getPointerInfo方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: drawCursor

import java.awt.MouseInfo; //導入方法依賴的package包/類
/**
  * Draws the cursor on the frame, if required.
  *
  * @param frame	the frame to update
  * @return		the (potentially) updated frame
  */
 protected BufferedImage drawCursor(BufferedImage frame) {
   PointerInfo 	pointer;

   if (m_CaptureMouse && (m_Cursor != null)) {
     pointer = MouseInfo.getPointerInfo();
     frame.getGraphics().drawImage(
m_Cursor,
(int) pointer.getLocation().getX() - m_X,
(int) pointer.getLocation().getY() - m_Y,
m_Cursor.getWidth(null),
m_Cursor.getHeight(null),
m_BackgroundColor,
null);
   }

   return frame;
 }
 
開發者ID:fracpete,項目名稱:screencast4j,代碼行數:24,代碼來源:AbstractScreenRecorder.java

示例2: createCurrent

import java.awt.MouseInfo; //導入方法依賴的package包/類
/**
 * Create a mouse movement event as if the mouse just
 * moved to its current position.
 * @param c the base swing component to relativize the mouse location
 * @return the mouse event
 */
public static UIMouse createCurrent(Component c) {
	UIMouse m = new UIMouse();
	m.type = UIMouse.Type.MOVE;
	PointerInfo pointerInfo = MouseInfo.getPointerInfo();
	if (pointerInfo != null) {
		Point pm = pointerInfo.getLocation();
		Point pc = new Point(0, 0);
		try {
			pc = c.getLocationOnScreen();
		} catch (IllegalStateException ex) {
			// ignored
		}
		m.x = pm.x - pc.x;
		m.y = pm.y - pc.y;
	}
	return m;
}
 
開發者ID:akarnokd,項目名稱:open-ig,代碼行數:24,代碼來源:UIMouse.java

示例3: checkMouseLocation

import java.awt.MouseInfo; //導入方法依賴的package包/類
/**
 * Check if mouse location has changed from previous check.
 */
private static void checkMouseLocation() {
    PointerInfo info = MouseInfo.getPointerInfo();
    // This can sometimes be null, so check for it (e.g. when Windows' UAC
    // screen is active)
    if (info == null) {
        return;
    }
    Point currentLocation = info.getLocation();
    
    if (lastLocation != null && !lastLocation.equals(currentLocation)) {
        lastMoved = System.currentTimeMillis();
        triggerActivity();
    }
    lastLocation = currentLocation;
}
 
開發者ID:chatty,項目名稱:chatty,代碼行數:19,代碼來源:ActivityTracker.java

示例4: doLeftClick

import java.awt.MouseInfo; //導入方法依賴的package包/類
@Override
protected void doLeftClick(final Point point) throws InterruptedException {
    // TODO non funziona
    final PointerInfo a = MouseInfo.getPointerInfo();
    final java.awt.Point b = a.getLocation();
    final int xOrig = (int) b.getX();
    final int yOrig = (int) b.getY();
    try {
        final Point p = clientToScreen(point);
        robot.mouseMove(p.x(), p.y());
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
    } finally {
        robot.mouseMove(xOrig, yOrig);
    }
}
 
開發者ID:paspiz85,項目名稱:nanobot,代碼行數:17,代碼來源:BlueStacksMacPlatform.java

示例5: buildPopup

import java.awt.MouseInfo; //導入方法依賴的package包/類
private JPopupMenu buildPopup(Map<Class, StepDescription> stepMap) {
	JPopupMenu pop = new JPopupMenu();
	
	JMenu add = new JMenu("Add Transformer");
	JMenuItem labelMenuItem = new JMenuItem("Add Label");
	//figure out where the user clicked
	
	PointerInfo pi = MouseInfo.getPointerInfo();
       Point startLocation = pi.getLocation();
       SwingUtilities.convertPointFromScreen(startLocation,this);
       labelMenuItem.addActionListener(new AddLabelAction(this, startLocation));
	pop.add(add);
	pop.add(labelMenuItem);
	
	StepDescription[] sds = stepMap.values().toArray(new StepDescription[0]);
	Arrays.sort(sds);
	for (StepDescription sd : sds) {
		JMenuItem item = new JMenuItem(sd.getName(), sd.getIcon());
		item.addActionListener(new AddStepActon(sd.getLogicClass()));
		add.add(item);
	}
	
	return pop;
}
 
開發者ID:SQLPower,項目名稱:power-matchmaker,代碼行數:25,代碼來源:MungePen.java

示例6: init

import java.awt.MouseInfo; //導入方法依賴的package包/類
public void init() {
	frame = new JFrame("Recursive Directory Removal Pro "+RdProUI.version);
	frame.setContentPane(layoutPanel1);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	frame.pack();

	/*position it*/
	//frame.setLocationRelativeTo(null);  // *** this will center your app ***
	PointerInfo a = MouseInfo.getPointerInfo();
	Point b = a.getLocation();
	int x = (int) b.getX();
	int y = (int) b.getY();
	frame.setLocation(x + 100, y);

	btnEditRootDir.setBorder(null);
	btnCancel.setText("Close");
	//resize();

	frame.setVisible(true);

}
 
開發者ID:mhisoft,項目名稱:rdpro,代碼行數:23,代碼來源:ReproMainForm.java

示例7: mouseMove

import java.awt.MouseInfo; //導入方法依賴的package包/類
/**
 * 處理鼠標移動
 */
public void mouseMove(String info) {
    String args[] = info.split(",");
    String x = args[0];
    String y = args[1];
    float px = Float.valueOf(x);
    float py = Float.valueOf(y);

    PointerInfo pinfo = MouseInfo.getPointerInfo(); // 得到鼠標的坐標
    java.awt.Point p = pinfo.getLocation();
    double mx = p.getX(); // 得到當前電腦鼠標的坐標
    double my = p.getY();
    try {
        java.awt.Robot robot = new Robot();
        robot.mouseMove((int) (mx + px), (int) (my + py));
    } catch (AWTException e) {
    }
}
 
開發者ID:kymjs,項目名稱:KJController,代碼行數:21,代碼來源:Main.java

示例8: run

import java.awt.MouseInfo; //導入方法依賴的package包/類
@Override
public void run() {
	terminate = false;
	PointerInfo pointerInfo = MouseInfo.getPointerInfo();
	Point pointerLocation = pointerInfo.getLocation();
	mouseX = pointerLocation.getX();
	mouseY = pointerLocation.getY();
	while (!terminate) {
		try {
			mouseX += (x * Math.abs(x) * 100);
			mouseY += (y * Math.abs(y) * 100);
			robot.mouseMove(new Double(mouseX).intValue(), new Double(mouseY).intValue());
			Thread.sleep(10);
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
	mouseX = null;
	mouseY = null;
}
 
開發者ID:da-baumann,項目名稱:dev,代碼行數:21,代碼來源:PointerStickExecuter.java

示例9: focusGained

import java.awt.MouseInfo; //導入方法依賴的package包/類
@Override
public void focusGained(FocusEvent e) {
	this.stateTransitionTracker.turnOffModelChangeTracking();
	try {
		super.focusGained(e);
		if (!this.button.isShowing()) {
			// shouldn't happen. Is some lurking Swing bug
			return;
		}
		try {
			PointerInfo pi = MouseInfo.getPointerInfo();
			int px = pi.getLocation().x
					- this.button.getLocationOnScreen().x;
			int py = pi.getLocation().y
					- this.button.getLocationOnScreen().y;
			this.button.getModel()
					.setRollover(this.button.contains(px, py));
		} catch (AccessControlException ace) {
			// sandbox - give up
		}
	} finally {
		this.stateTransitionTracker.onModelStateChanged();
	}
}
 
開發者ID:Depter,項目名稱:JRLib,代碼行數:25,代碼來源:RolloverButtonListener.java

示例10: getCurrentCursorLocation

import java.awt.MouseInfo; //導入方法依賴的package包/類
private Point getCurrentCursorLocation() {
    Point res = null;
    PointerInfo pi = MouseInfo.getPointerInfo();
    if( null != pi ) {
        res = pi.getLocation();
    }
    return res;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:WindowSnapper.java

示例11: getScreenBounds

import java.awt.MouseInfo; //導入方法依賴的package包/類
private Rectangle getScreenBounds() {
    Rectangle res = null;
    PointerInfo pi = MouseInfo.getPointerInfo();
    if( null != pi ) {
        GraphicsDevice gd = pi.getDevice();
        if( gd != null ) {
            GraphicsConfiguration gc = gd.getDefaultConfiguration();
            if( gc != null ) {
                res = gc.getBounds();
            }
        }
    }
    return res;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:WindowSnapper.java

示例12: ensureSelected

import java.awt.MouseInfo; //導入方法依賴的package包/類
/** Workaround for JDK bug 6663119, it ensures that first item in submenu
 * is correctly selected during keyboard navigation.
 */
private void ensureSelected () {
    if (menu.getMenuComponentCount() <=0) {
        return;
    }
    
    Component first = menu.getMenuComponent(0);
    if (!(first instanceof JMenuItem)) {
        return;
    }
    PointerInfo pointerInfo = MouseInfo.getPointerInfo();
    if (pointerInfo == null) {
        return; // probably a mouseless computer
    }
    Point loc = pointerInfo.getLocation();
    SwingUtilities.convertPointFromScreen(loc, menu);
    MenuElement[] selPath =
            MenuSelectionManager.defaultManager().getSelectedPath();
    
    // apply workaround only when mouse is not hovering over menu
    // (which signalizes mouse driven menu traversing) and only
    // when selected menu path contains expected value - submenu itself 
    if (!menu.contains(loc) && selPath.length > 0 && 
            menu.getPopupMenu() == selPath[selPath.length - 1]) {
        // select first item in submenu through MenuSelectionManager
        MenuElement[] newPath = new MenuElement[selPath.length + 1];
        System.arraycopy(selPath, 0, newPath, 0, selPath.length);
        JMenuItem firstItem = (JMenuItem)first;
        newPath[selPath.length] = firstItem;
        MenuSelectionManager.defaultManager().setSelectedPath(newPath);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:35,代碼來源:RecentFileAction.java

示例13: update

import java.awt.MouseInfo; //導入方法依賴的package包/類
@Override
public void update() throws Exception
{
	PointerInfo pi = MouseInfo.getPointerInfo();
	Point epoint = pi == null ? lastCursorPoint : pi.getLocation();
	if (!epoint.equals(lastCursorPoint))
	{
		lastCursorPoint = epoint;
		MainDialog.resetActivityTimer(MOUSE_POINTER);
	}
}
 
開發者ID:PolyphasicDevTeam,項目名稱:NoMoreOversleeps,代碼行數:12,代碼來源:IntegrationMouse.java

示例14: doSetFocus

import java.awt.MouseInfo; //導入方法依賴的package包/類
@Override
protected void doSetFocus() {
	text.setFocus();
	text.setSelection(text.getText().length());

	if (cmode.isDirectlyConnected() && Activator.getStore().getBoolean(DevicePreferenceConstants.SHOW_CONTROL_TOOLTIPS)) {
		PointerInfo a = MouseInfo.getPointerInfo();
		java.awt.Point loc = a.getLocation();

		tip.setLocation(loc.x, loc.y+20);
        tip.setVisible(true);
	}
}
 
開發者ID:eclipse,項目名稱:scanning,代碼行數:14,代碼來源:ControlValueCellEditor.java

示例15: showTip

import java.awt.MouseInfo; //導入方法依賴的package包/類
/**
    * Show the top where the mouse is.
    * @param tip
    * @param message
    */
public static void showTip(ToolTip tip, String message) {

	if (tip==null) return;
tip.setMessage(message);
	PointerInfo a = MouseInfo.getPointerInfo();
	java.awt.Point loc = a.getLocation();

	tip.setLocation(loc.x, loc.y+20);
       tip.setVisible(true);
}
 
開發者ID:eclipse,項目名稱:scanning,代碼行數:16,代碼來源:ViewUtil.java


注:本文中的java.awt.MouseInfo.getPointerInfo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。