X & Y of the following event "Mouse clicked"
the program I have to write should be able to create a rectangle in a JScrollPane.
My goal would be to create a JMenuBar with a JMenuItem called "New rectangle" which, if pressed, will create the rectangle in the next point of the JScrollPane clicked by the mouse. So far I just succeed into having the rectangle created in a particular point by manually inserting the X and Y in the code, but I would like to create it in the getX () and getY () of the following point in which the user press the mouse.
Is it possible to do such a thing?
Thanks in advance.