gpt4 book ai didi

java - 如何使用 JOGL2 隐藏鼠标光标?

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:34:45 25 4
gpt4 key购买 nike

我正在使用 JOGL2 和 NativeWindow API 用 Ja​​va 编写应用程序。如何隐藏鼠标光标?

[编辑]
我没有使用 JFrame 创建窗口,而是使用 JOGL 的 GLWindow。 GLWindow 没有 setCursor 方法。这还有可能吗?

最佳答案

正如你(开玩笑的人)所说,GLWindow 没有这种能力,所以我会在 Frame(或 JFrame)中使用 GLCanvas ) 像这样(就像 AlexR 写的那样):

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);
}

关于java - 如何使用 JOGL2 隐藏鼠标光标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4317842/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com