Hey

Im having a hard trouble drawing in a Java window so if there is a plugin that shows the coordinates in a Java window when I hover my mouse over that spot it would make my coordinate easier.

you can implement a mouse motion listener:

http://download.oracle.com/javase/tutorial/uiswing/events/mousemotionlistener.html

and in on the mouse movement method track x,y to a variable to use in your paint components.

you can implement a mouse listener to detect clicks

http://download.oracle.com/javase/tutorial/uiswing/events/mouselistener.html

on a click write the current x,y as motion has updated it to writableX and writabley, then call repaint(), and then in your paint method use DrawString to write the cordinates of that click out somewhere in window.

if your drawing on a panel, make your panel class implement both listners. use the add method to add both listeners, and then you just need to copy in the methods of each listener ( with no code in at first). then add the code as i outlined, writing the x,y in motion and writing the writable x,y in click and repaint. You will get error methods if you use the implement and add but fail to copy in all methods. there is maybe 4 or 5 for each.

Mike

You can actually just use a motion listener and on each call to change in motion, mouse dragged in think, assign x,y and repaint and use drawstring in paint to print where the mouse is hovering at the moment, at a given spot like 50,50 on screen.

Mike

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.