set mouse pointer relative to application

Hello all:

I want to set mouse cursor position in a JPanel.

I found an example as follows:
Moving the Cursor on the Screen


try {
// These coordinates are screen coordinates
int xCoord = 500;
int yCoord = 500;

// Move the cursor
Robot robot = new Robot();
robot.mouseMove(xCoord, yCoord);
} catch (AWTException e) {
}

But this setting is special for whole screen.
I only want to move mouse cursor position relative to my Application

is there anyway I could do it?

thank you

You can get the position of your component on the screen with getLocationOnScreen, and then
calculate the coordinates for the mouse pointer based on that.

Use SwingUtilities methods:

SwingUtilities.convertPointFromScreen(Point p, Component c)
SwingUtilities.convertPointToScreen(Point p, Component c) 

Thanks alot!