Recently bored to play new tricks, need to get screen coordinates, before this thing is directly installed someone else's EXE tool, now think of themselves also count the program Ape, write a bar
In fact, it is not difficult, in general, is to create a panel, and then real-time monitoring the position of the mouse to display it
For the position of the mouse can be obtained in MouseEvent E's E.getx () and E.gety () methods, the code is as follows:
public void mousemoved (MouseEvent e) {
int x = E.getx ();
int y = e.gety ();
String s = "Current mouse coordinates: (" + x + "," + y + ")";
MouseMove.lab.setText (s);
}
Then find a place of your own to show it
Because you get the entire screen, you also want to get the screen size and hide the title bar, as follows:
Get screen Size
static Dimension screensize = Toolkit.getdefaulttoolkit (). Getscreensize ();
int width = (int) screensize.getwidth ();
int height = (int) screensize.getheight ();
Hide title bar
Fm.setundecorated (TRUE);
Note here that the statement that hides the title bar is placed before setvisible ()
(Java) Get mouse position coordinates