i have to get both the co-ordinates
I don't understand what this means. From where are you getting the coordinates?
If you're talking of detecting where the mouse points to, then you need to add a MouseMotionListener. It supplies the code with MouseEvents, which have the X/Y information where the mouse is.