Search in sources :

Example 1 with PointerInfo

use of java.awt.PointerInfo in project bigbluebutton by bigbluebutton.

the class MouseLocationTaker method getMouseLocation.

private Point getMouseLocation() {
    PointerInfo pInfo;
    Point pointerLocation = new Point(0, 0);
    try {
        pInfo = MouseInfo.getPointerInfo();
    } catch (HeadlessException e) {
        pInfo = null;
    } catch (SecurityException e) {
        pInfo = null;
    }
    if (pInfo == null)
        return pointerLocation;
    return pInfo.getLocation();
}
Also used : PointerInfo(java.awt.PointerInfo) HeadlessException(java.awt.HeadlessException) Point(java.awt.Point)

Example 2 with PointerInfo

use of java.awt.PointerInfo in project ACS by ACS-Community.

the class TreeMouseListener method mousePressed.

/**
	 * @see java.awt.event.MouseListener
	 */
public void mousePressed(MouseEvent e) {
    TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
    if (selPath == null) {
        // No object selected but the user expand/compress a node
        return;
    }
    if (e.getClickCount() == 2) {
        tree.setSelectionPath(selPath);
        /*class TabShower implements Runnable {
				TreePath selectedPath;
				public TabShower(TreePath path) {
					selectedPath=path;
				}
				public void run() {
					showLoggingConfigTab(selectedPath);
				}
			};
			TabShower shower = new TabShower(selPath);
			Thread t = new Thread(shower);
			t.run();*/
        showLoggingConfigTab(selPath);
        return;
    }
    if (e.isPopupTrigger()) {
        //Toolkit tk = Toolkit.getDefaultToolkit();
        PointerInfo pi = MouseInfo.getPointerInfo();
        Point mouseLocation = pi.getLocation();
        SwingUtilities.convertPointFromScreen(mouseLocation, tree);
        popupMenu.show(tree, mouseLocation.x, mouseLocation.y);
    }
}
Also used : PointerInfo(java.awt.PointerInfo) TreePath(javax.swing.tree.TreePath) Point(java.awt.Point)

Example 3 with PointerInfo

use of java.awt.PointerInfo in project adempiere by adempiere.

the class VPOS method init.

@Override
public void init(int WindowNo, FormFrame frame) {
    this.frame = frame.getCFrame();
    this.frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    this.frame.setResizable(true);
    //	
    logger.info("init - SalesRep_ID=" + Env.getAD_User_ID(getCtx()));
    setWindowNo(WindowNo);
    frame.setJMenuBar(null);
    if (!loadPOS()) {
        EventQueue.invokeLater(new Runnable() {

            public void run() {
                CFrame closeFrame = frame.getCFrame();
                closeFrame.dispatchEvent(new WindowEvent(closeFrame, WindowEvent.WINDOW_CLOSING));
                dispose();
            }
        });
        return;
    }
    userPinListener = new POSUserPinListener(this);
    //Delay 5 seconds by default
    userPinTimer = new javax.swing.Timer((getPINEntryTimeout() + 10) * 1000, userPinListener);
    if (isPresentElectronicScales()) {
        scalesListener = new POSScalesListener(this);
        scalesTimer = new javax.swing.Timer(400, scalesListener);
    }
    isCorrectUserPin = null;
    settingKeyboardFocusManager();
    if (getM_POS() == null) {
        if (this.frame != null)
            this.frame.dispose();
        return;
    }
    //
    try {
        if (!dynInit()) {
            dispose();
            return;
        }
        //	Add to frame
        frame.getContentPane().add(mainPanel, BorderLayout.CENTER);
    } catch (AdempierePOSException exception) {
        ADialog.error(getWindowNo(), this.frame, exception.getLocalizedMessage());
        dispose();
        return;
    }
    logger.config("PosPanel.init - " + mainPanel.getPreferredSize());
    if (getAutoLogoutDelay() > 0 && logoutTimer == null) {
        logoutTimer = new javax.swing.Timer(1000, new ActionListener() {

            PointerInfo pi = null;

            long lastMouseMove = System.currentTimeMillis();

            long lastKeyboardEvent = System.currentTimeMillis();

            public void actionPerformed(ActionEvent actionEvent) {
                try {
                    long now = actionEvent.getWhen();
                    PointerInfo newPi = MouseInfo.getPointerInfo();
                    // mouse moved
                    if (newPi != null && pi != null && !pi.getLocation().equals(newPi.getLocation())) {
                        lastMouseMove = now;
                    }
                    pi = newPi;
                    if (isVirtualKeyboard())
                        lastKeyboardEvent = focusManager.getLastWhen();
                    else
                        lastKeyboardEvent = 0;
                    if (getAutoLogoutDelay() * 1000 < now - Math.max(lastKeyboardEvent, lastMouseMove)) {
                    //	new PosLogin(this);
                    }
                } catch (AdempiereException exception) {
                    ADialog.error(getWindowNo(), getFrame(), exception.getLocalizedMessage());
                }
            }
        });
        logoutTimer.start();
    }
    if (isVirtualKeyboard())
        focusManager.start();
}
Also used : ActionEvent(java.awt.event.ActionEvent) CFrame(org.compiere.swing.CFrame) PointerInfo(java.awt.PointerInfo) ActionListener(java.awt.event.ActionListener) AdempiereException(org.adempiere.exceptions.AdempiereException) WindowEvent(java.awt.event.WindowEvent) Timer(javax.swing.Timer)

Example 4 with PointerInfo

use of java.awt.PointerInfo in project bigbluebutton by bigbluebutton.

the class ScreenCapture method getMouseLocation.

private Point getMouseLocation() {
    PointerInfo pInfo;
    Point pointerLocation = new Point(0, 0);
    try {
        pInfo = MouseInfo.getPointerInfo();
    } catch (HeadlessException e) {
        pInfo = null;
    } catch (SecurityException e) {
        pInfo = null;
    }
    if (pInfo == null)
        return pointerLocation;
    return pInfo.getLocation();
}
Also used : PointerInfo(java.awt.PointerInfo) HeadlessException(java.awt.HeadlessException) Point(java.awt.Point)

Example 5 with PointerInfo

use of java.awt.PointerInfo in project lwjgl by LWJGL.

the class AWTUtil method getPointerLocation.

/**
	 * Use reflection to access the JDK 1.5 pointer location, if possible and
	 * only if the given component is on the same screen as the cursor. Return
	 * null otherwise.
	 */
private static Point getPointerLocation(final Component component) {
    try {
        final GraphicsConfiguration config = component.getGraphicsConfiguration();
        if (config != null) {
            PointerInfo pointer_info = AccessController.doPrivileged(new PrivilegedExceptionAction<PointerInfo>() {

                public PointerInfo run() throws Exception {
                    return MouseInfo.getPointerInfo();
                }
            });
            GraphicsDevice device = pointer_info.getDevice();
            if (device == config.getDevice()) {
                return pointer_info.getLocation();
            }
            return null;
        }
    } catch (Exception e) {
        LWJGLUtil.log("Failed to query pointer location: " + e.getCause());
    }
    return null;
}
Also used : PointerInfo(java.awt.PointerInfo) GraphicsDevice(java.awt.GraphicsDevice) IllegalComponentStateException(java.awt.IllegalComponentStateException) PrivilegedActionException(java.security.PrivilegedActionException) LWJGLException(org.lwjgl.LWJGLException) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Aggregations

PointerInfo (java.awt.PointerInfo)5 Point (java.awt.Point)3 HeadlessException (java.awt.HeadlessException)2 GraphicsConfiguration (java.awt.GraphicsConfiguration)1 GraphicsDevice (java.awt.GraphicsDevice)1 IllegalComponentStateException (java.awt.IllegalComponentStateException)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 WindowEvent (java.awt.event.WindowEvent)1 PrivilegedActionException (java.security.PrivilegedActionException)1 Timer (javax.swing.Timer)1 TreePath (javax.swing.tree.TreePath)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 CFrame (org.compiere.swing.CFrame)1 LWJGLException (org.lwjgl.LWJGLException)1