在Swing中,有没有办法从工具包中提取预定义的鼠标光标Image? [英] In Swing, is there a way to extract a predefined mouse cursor Image from the toolkit?

查看:100
本文介绍了在Swing中,有没有办法从工具包中提取预定义的鼠标光标Image?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户将鼠标悬停在可以单击以获取上下文相关帮助的对象上时,我想通过使用问号标记内置默认鼠标光标来制作自定义帮助光标。我希望这可以很好地跨平台/外观工作(例如,与白色Windows鼠标和黑色Mac鼠标一致。)有没有办法从当前工具包中获取光标图像,以便我可以生成一个组合图像来设置为光标吗?

I'd like to make a custom help cursor by "badging" the built-in default mouse cursor with a question mark when the user is hovering over an object that can be clicked for context-sensitive help. I'd like this to work nicely across platforms/look-and-feels (to look consistent with the white Windows mouse and the black Mac mouse, for instance.) Is there a way to get the cursor Image from the current Toolkit so that I could generate a combined Image to set as the cursor?

这个问题指出无法从Cursor对象获取信息。还有一个评论建议在JRE中钓鱼,我也尝试了一下:在谷歌图片中,我没有找到任何直接可访问的图形文件来掠夺

This question points out that the information can't be gotten from the Cursor object. There's also a comment there that suggested fishing around in the JRE, which I've also tried a bit: There and in google images, I didn't find any straightforwardly accessible graphics files to plunder

另一种方法是添加一个mouseMoved监听器,并在光标右侧手动绘制一下(我想在父级上,以避免在边界处剪切?)但是我有点担心开销,在最初的探索中,这看起来非常复杂。我会采取其他建议来寻找或制作一个很好的帮助光标。 (手是最好的内置,但它没有像问号一样明确地说帮助。)

An alternative would be to add a mouseMoved listener and draw manually a little to the right of the cursor (on the parent, I suppose, to avoid clipping at the borders?) but I was a bit concerned about overhead, and in initial explorations, this was looking very complicated. I'd take other suggestions about finding or making a nice help cursor as well. (The hand is the best built-in, but it doesn't say "help" as clearly as a question-mark.)

推荐答案

我不确定这是你个案中最好的解决方案,因为一个好的内置鼠标光标应该是最好的。无论如何,您可以使用鼠标监听器并根据鼠标位置在玻璃板上绘图。 这是玻璃窗绘图示例。

I'm not sure this is the best solution in your case, because a good built-in mouse cursor should be the best. Anyway you can use mouse listeners and draw on a glasspane according to the mouse position. Here's a glasspane drawing example.

这篇关于在Swing中,有没有办法从工具包中提取预定义的鼠标光标Image?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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