简体   繁体   English

如何声明JOGL Newt MouseEvent?

[英]How to declare a JOGL Newt MouseEvent?

I am currently using JOGL the OpenGL Java port and I need to use the com.jogamp.newt.event.MouseEvent 我目前正在使用JOGL和OpenGL Java端口,并且需要使用com.jogamp.newt.event.MouseEvent

I don't know how to declare it, I found this documentation about it but I am still confused as to how I declare it 我不知道如何声明它,我找到了有关它的文档 ,但是我仍然对如何声明它感到困惑

When I just did 我刚做的时候

public MouseEvent mouseEvent;

and tried to use mouseEvent.getX() 并尝试使用mouseEvent.getX()

It returned a null pointer exception, I then tried 它返回一个空指针异常,然后我尝试

public MouseEvent mouseEvent = new MouseEvent();

But that needs some values inside the parenthesis which is what I am confused about 但这需要括号内的一些值,这让我感到困惑

Unless you know exactly what you are doing, don't create a MouseEvent yourself. 除非您确切知道自己在做什么,否则不要自己创建MouseEvent

Rather, you need to have a class implementing the jogamp MouseListener and add that to your GLWindow , like I am doing here for example 相反,您需要一个实现jogamp MouseListener的类,并将其添加到您的GLWindow ,例如我在这里做的那样

Then override the following methods: 然后覆盖以下方法:

@Override
public void mouseClicked(MouseEvent e) {    }

@Override
public void mouseEntered(MouseEvent e) {    }

@Override
public void mouseExited(MouseEvent e) {    }

@Override
public void mousePressed(MouseEvent e) {    }

@Override
public void mouseReleased(MouseEvent e) {    }

@Override
public void mouseMoved(MouseEvent e) {    }

@Override
public void mouseDragged(MouseEvent e) {    }

@Override
public void mouseWheelMoved(MouseEvent e) {    }

And you are good to go 而且你很好走

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM