java程序中隐藏光标隐藏光标_java – 如何在Swing应用程序中隐藏光标?

看起来

Cursor类没有一个“空白”光标开始,所以可以使用

Toolkit.createCustomCursor方法定义一个新的“空白”光标。

这里有一种方法,我试过似乎工作:

// Transparent 16 x 16 pixel cursor image.

BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);

// Create a new blank cursor.

Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(

cursorImg, new Point(0, 0), "blank cursor");

// Set the blank cursor to the JFrame.

mainJFrame.getContentPane().setCursor(blankCursor);

编辑

关于JFrame中没有光标的所有内容的评论,看起来JFrame中包含的组件最终会继承容器的游标(JFrame),所以如果它是一个需要有一个特定组件有光标出现,必须手动设置所需的光标。

例如,如果JFrame中包含JPanel,那么可以使用Cursor.getDefaultCursor方法将该JPanel的光标设置为系统的默认值:

JPanel p = ...

// Sets the JPanel's cursor to the system default.

p.setCursor(Cursor.getDefaultCursor());

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值