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();
}
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);
}
}
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();
}
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();
}
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;
}
Aggregations