Mouse click coordinates are always 0

北城余情 提交于 2019-12-07 03:55:30
public int x, y;

int variables are always initialized to 0.

public void MousePressed(MouseEvent e)

Method names are case sensitive.

Your code is never executed since the method to override should be mousePressed(...). Fix the typo in your code.

Always use code like:

@Override
public void mousePressed(MouseEvent e)

Then if you make a typo the compiler will tell you.

When I try to get the X, and Y coordinates they are always 0

Since your code is never executed the default value is returned.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!