Posted By:
rajiv_r
Posted On:
Friday, August 13, 2004 11:16 AM
Hi, I am using the exclusive full screen mode api for my java swing program. I am trying to use the Jbutton's getLocationOnScreen() function. The problem is that this is returning me some negative and worng values. However, when I remove the full screen api mode, the same function gives me the right co-ordinates. I am basically just looking at getting the absolute position of the mouse on the screen (Which is a JFrame with nested components). Any help would be appreciated. Code to Make full screen that I am using :- GraphicsDevice defaultGraphicsDeviceObj = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().ge
More>>
Hi,
I am using the exclusive full screen mode api for my java swing program.
I am trying to use the Jbutton's getLocationOnScreen() function. The problem is that this is returning me some negative and worng values.
However, when I remove the full screen api mode, the same function gives me the right co-ordinates.
I am basically just looking at getting the absolute position of the mouse on the screen (Which is a JFrame with nested components). Any help would be appreciated.
Code to Make full screen that I am using :-
GraphicsDevice defaultGraphicsDeviceObj = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
defaultGraphicsDeviceObj.setFullScreenWindow(this);
Code to get the mouse location :-
public void mousePressed(MouseEvent arg0)
{
Point pointObj = arg0.getPoint();
Point temp = ( (JButton) arg0.getSource) ).getLocationOnScreen();
pointObj.x = (int) (pointObj.x + ( (JButton) arg0.getSource() ).getLocationOnScreen().getX()) );
pointObj.y = (int) (pointObj.y + ( (JButton)
arg0.getSource() ).getLocationOnScreen().getY()) );
currentMouseLocation = pointObj;
}
Thanks,
Rajiv
<<Less