My aim is to read coordinate point values from a graph in a Java program. I don't know if it even needs to be a graph. The user clicks on various parts of a plane, and I need to know which places were clicked pixel-wise so that I can find the distances between those points. Are there any simple Java lib开发者_如何学Pythonraries for accomplishing this task?
Just add a mouse listener to a JPanel.
In the mouse listener, you can do something like the following:
public void mouseClicked(MouseEvent e) {
System.out.println("Mouse clicked at (" + e.getX() +"," +
+ e.getY + ")");
}
精彩评论