How to use jogl2 to hide the mouse cursor?

I am using jogl2 and nativewindow APIs to write Java applications What is the best / easiest way to hide the mouse cursor?

[Edit] instead of using JFrame to create a window, I use the GL window of jogl GLWindow has no SETCURSOR method Is this still possible?

Solution

As you said, GLWindow does not have that ability, so I will use glcanvas in such a framework (or JFrame) (as written by Alex R):

public static void main(String... args) {

    // create the cursor
    Toolkit t = Toolkit.getDefaultToolkit();
    Image i = new BufferedImage(1,1,BufferedImage.TYPE_INT_ARGB);
    Cursor noCursor = t.createCustomCursor(i,new Point(0,0),"none"); 

    // try it with a normal frame
    Frame f = new Frame();

    // create the GLCanvas and add it to the frame
    GLCanvas canvas = new GLCanvas();
    frame.add(canvas);

    f.setCursor(noCursor);
    f.setSize(400,200);
    f.setVisible(true);
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>