Java 类java.awt.PointerInfo 实例源码
项目:screencast4j
文件:AbstractScreenRecorder.java
/**
* 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;
}
项目:PhET
文件:AWTUtil.java
/**
* 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;
}
项目:screencast4j
文件:AbstractScreenRecorder.java
/**
* 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;
}
项目:open-ig
文件:UIMouse.java
/**
* 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;
}
项目:chatty
文件:ActivityTracker.java
/**
* 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;
}
项目:nanobot
文件:BlueStacksMacPlatform.java
@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);
}
}
项目:power-matchmaker
文件:MungePen.java
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;
}
项目:Chatty-Twitch-Client
文件:ActivityTracker.java
/**
* 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;
}
项目:Wolf_game
文件:AWTUtil.java
/**
* 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;
}
项目:rdpro
文件:ReproMainForm.java
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);
}
项目:KJController
文件:Main.java
/**
* 处理鼠标移动
*/
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) {
}
}
项目:TwitchChatClient
文件:ActivityTracker.java
/**
* 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;
}
项目:GPVM
文件:AWTUtil.java
/**
* 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;
}
项目:GPVM
文件:AWTUtil.java
/**
* 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;
}
项目:SpaceStationAlpha
文件:AWTUtil.java
/**
* 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;
}
项目:TeacherSmash
文件:AWTUtil.java
/**
* 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;
}
项目:3d-Demo
文件:AWTUtil.java
/**
* 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;
}
项目:dev
文件:PointerStickExecuter.java
@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;
}
项目:JRLib
文件:RolloverButtonListener.java
@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();
}
}
项目:incubator-netbeans
文件:WindowSnapper.java
private Point getCurrentCursorLocation() {
Point res = null;
PointerInfo pi = MouseInfo.getPointerInfo();
if( null != pi ) {
res = pi.getLocation();
}
return res;
}
项目:incubator-netbeans
文件:WindowSnapper.java
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;
}
项目:incubator-netbeans
文件:RecentFileAction.java
/** 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);
}
}
项目:NoMoreOversleeps
文件:IntegrationMouse.java
@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);
}
}
项目:scanning
文件:ControlValueCellEditor.java
@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);
}
}
项目:scanning
文件:ViewUtil.java
/**
* 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);
}
项目:AutonomousCar
文件:LooiWindow.java
/**
* Returns the mouse x position in the entire screen
* @return
*/
public static int getScreenMouseX()
{
PointerInfo p = MouseInfo.getPointerInfo();
Point b = p.getLocation();
return (int)b.getX();
}
项目:AutonomousCar
文件:LooiWindow.java
/**
* Returns the mouse y position in the entire screen
* @return
*/
public static int getScreenMouseY()
{
PointerInfo p = MouseInfo.getPointerInfo();
Point b = p.getLocation();
return (int)b.getY();
}
项目:WhatsappCrush
文件:WhatsappCrushGUI.java
@Override
public void focusLost(FocusEvent e) {
PointerInfo pi = MouseInfo.getPointerInfo();
Point p = pi.getLocation();
System.out.println("X is " + p.x);
System.out.println("Y is " + p.y);
x = p.x;
y = p.y;
button1.setLabel("Try Again");
label.setText("Successfully Clicked. Ready to Start Crushing...");
label.setBackground(Color.GREEN);
button2.setEnabled(true);
button1.removeFocusListener(focusListerner);
}
项目:iBioSim
文件:Schematic.java
public int[] getPosition(int x, int y) {
int[] xy = new int[2];
if (x < 0 && y < 0) {
PointerInfo a = MouseInfo.getPointerInfo();
Point c = graphComponent.getLocationOnScreen();
Point b = a.getLocation();
x = (int)(b.getX() - c.getX());
y = (int)(b.getY() - c.getY());
}
if (x<0) x = 0;
if (y<0) y = 0;
xy[0] = x;
xy[1] = y;
return xy;
}
项目:swingx
文件:RolloverProducer.java
/**
* @param e
*/
private void updateRollover(ComponentEvent e) {
Point componentLocation = null;
try {
componentLocation = e.getComponent().getMousePosition();
} catch (ClassCastException ignore) {
// caused by core issue on Mac/Java 7
//try to work our way there by a different path
//*sigh* this requires permissions
//if this fails, rollover is effectively neutered
Window w = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
if (w != null && isDescendingFrom(e.getComponent(), w)) {
try {
PointerInfo pi = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<PointerInfo>() {
@Override
public PointerInfo run() {
return MouseInfo.getPointerInfo();
}
}
);
componentLocation = pi.getLocation();
convertPointFromScreen(componentLocation, e.getComponent());
} catch (SecurityException se) { }
}
}
if (componentLocation == null) {
componentLocation = new Point(-1, -1);
}
// LOG.info("" + componentLocation + " / " + e);
updateRolloverPoint((JComponent) e.getComponent(), componentLocation);
updateClientProperty((JComponent) e.getComponent(), ROLLOVER_KEY, true);
}
项目:stendhal
文件:StendhalFirstScreen.java
/**
* Detect the preferred screen by where the mouse is the moment the method
* is called. This is for multi-monitor support.
*
* @return GraphicsEnvironment of the current screen
*/
private static GraphicsConfiguration detectScreen() {
PointerInfo pointer = MouseInfo.getPointerInfo();
if (pointer != null) {
return pointer.getDevice().getDefaultConfiguration();
}
return null;
}
项目:AppWoksUtils
文件:ScreenShooter.java
@Override
public void mouseMoved(final MouseEvent e) {
if (e != null) {
this.mouse = e.getPoint();
} else {
final PointerInfo pi = MouseInfo.getPointerInfo();
this.mouse = pi.getLocation();
}
}
项目:gscrot
文件:ScreenshotHelper.java
/**
* Gets current screen bounds where mouse pointer is
* @return
* @throws Exception
*/
public static Rectangle getCurrentScreen() throws Exception {
PointerInfo i = MouseInfo.getPointerInfo();
GraphicsDevice p = i.getDevice();
return p.getDefaultConfiguration().getBounds();
}
项目:sc2gears
文件:MousePrintRecorder.java
/**
* Returns the current location of the mouse cursor.<br>
* On Windows if the workstation is locked (the login screen is displayed), the mouse location is not available
* and <code>null</code> is returned. Also if a mouse is not present, <code>null</code> is returned.
* @return the current location of the mouse cursor.
*/
private Point getMouseLocation() {
final PointerInfo pointerInfo = MouseInfo.getPointerInfo();
if ( pointerInfo == null ) // Mouse not present?
return null;
final Point location = pointerInfo.getLocation();
// Some big random number is returned if the workstation is locked on Windows
if ( location.x < -20000 || location.x > 20000 || location.y < -20000 || location.y > 20000 )
return null;
return location;
}
项目:OnlineGameWithRMITech
文件:FlyPlayerClient.java
public void getMyPointer(){
Point p1 = frame.getLocation();
PointerInfo a = MouseInfo.getPointerInfo();
Point p = a.getLocation();
MyPointerX = (int) (p.getX() - p1.getX() - 20 );
MyPointerY = (int) (p.getY() - p1.getY() - 36 - 40 );
}
项目:tellervo
文件:MeasurePanel.java
private void toggleMouseTrigger(boolean selected) {
btnMouseTrigger.setSelected(selected);
updateInfoText();
if(selected)
{
PointerInfo a = MouseInfo.getPointerInfo();
mousePoint = a.getLocation();
// Transparent 16 x 16 pixel cursor image.
Image cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
// Create a new blank cursor.
Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(
cursorImg, new Point(), "blank cursor");
setCursor(blankCursor);
btnMouseTrigger.setBackground(Color.RED);
parent.repaint();
}
else
{
setCursor(Cursor.getDefaultCursor());
btnMouseTrigger.setBackground(parentBGColor);
parent.repaint();
}
}
项目:trygve
文件:MouseInfoClass.java
@Override public RTCode runDetails(final RTObject myEnclosedScope) {
final RTDynamicScope activationRecord = RunTimeEnvironment.runTimeEnvironment_.currentDynamicScope();
final PointerInfo pointerInfo = MouseInfo.getPointerInfo();
final RTPointerInfoObject retval = new RTPointerInfoObject(pointerInfo);
addRetvalTo(activationRecord);
activationRecord.setObject("ret$val", retval);
return super.nextCode();
}
项目:selenium-utils
文件:ScreenRecorder.java
/**
* Captures the mouse cursor.
*/
private void grabMouse() throws InterruptedException {
long now = System.currentTimeMillis();
if (now > getStopTime()) {
future.cancel(false);
return;
}
PointerInfo info = MouseInfo.getPointerInfo();
Point p = info.getLocation();
if (!info.getDevice().equals(captureDevice)
|| !captureArea.contains(p)) {
// If the cursor is outside the capture region, we
// assign Integer.MAX_VALUE to its location.
// This ensures that all mouse movements outside of the
// capture region get coallesced.
p.setLocation(Integer.MAX_VALUE, Integer.MAX_VALUE);
}
// Only create a new capture event if the location has changed
if (!p.equals(prevCapturedMouseLocation) || mouseWasPressed != mousePressedRecorded) {
Buffer buf = new Buffer();
buf.format = format;
buf.timeStamp = new Rational(now, 1000);
buf.data = p;
buf.header = mouseWasPressed;
mousePressedRecorded = mouseWasPressed;
mouseCaptures.put(buf);
prevCapturedMouseLocation.setLocation(p);
}
if (!mousePressed) {
mouseWasPressed = false;
}
}
项目:fastcopy
文件:FastCopyMainForm.java
public void init() {
frame = new JFrame("Fast Copy " + UI.version);
frame.setContentPane(layoutPanel1);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//progressBar1.setVisible(false);
progressBar1.setMaximum(100);
progressBar1.setMinimum(0);
progressPanel.setVisible(false);
//frame.setPreferredSize(new Dimension(1200, 800));
frame.setPreferredSize(new Dimension(UserPreference.getInstance().getDimensionX(), UserPreference.getInstance().getDimensionY()));
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);
btnHelp.setBorder(null);
frame.setVisible(true);
componentsList = ViewHelper.getAllComponents(frame);
setupFontSpinner();
ViewHelper.setFontSize(componentsList, UserPreference.getInstance().getFontSize());
}
项目:syobo
文件:Syobo.java
private void startSwingEDT() {
// AWTでマウスの位置を 50 秒ごとに検出
SwingUtilities.invokeLater(() -> {
Timer timer = new Timer(50, e -> {
PointerInfo info = MouseInfo.getPointerInfo();
Platform.runLater(() -> updateLocation(info.getLocation().getX(), info.getLocation().getY()));
});
timer.start();
});
}