开发者

How can I read coordinates from a graph in Java?

开发者 https://www.devze.com 2023-02-18 22:52 出处:网络
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 wer

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 + ")");
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消