如何在JavaFX中隐藏光标? [英] How to hide the cursor in JavaFX?

查看:365
本文介绍了如何在JavaFX中隐藏光标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用OpenJFX 8u40运行JDK 1.8.0_65。 JavaFX有 javafx.scene.Scene.setCursor ,类似于Swing中同名的方法,但与后者不同,将其设置为 Cursor。 NONE 仅在光标移动之前隐藏它,然后永久地返回 Cursor.DEFAULT 。我也尝试将透明图像设置为光标,但我得到了相同的结果。这个功能在OpenJFX中被破坏了吗?

I'm running JDK 1.8.0_65 with OpenJFX 8u40. JavaFX has javafx.scene.Scene.setCursor, analogous to a method of the same name in Swing, but unlike the later, setting it to Cursor.NONE only hides it until the cursor is moved, and then it goes back to Cursor.DEFAULT permanently. I also tried to set a transparent image as a cursor but I got the same result. Is this feature broken in OpenJFX?

推荐答案

对我来说这完美无缺:

public class cursor extends Application {

@Override
public void start(Stage primaryStage) {

    HBox root = new HBox();
    Scene scene =   new Scene(root);

    scene.setCursor(Cursor.NONE);       


    primaryStage.setScene(scene);
    primaryStage.setWidth(300);
    primaryStage.setHeight(300);
    primaryStage.show();
}

public static void main(String[] args) {
    launch(args);
}
}

这篇关于如何在JavaFX中隐藏光标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆