Is there a way to hide cursor (other than using transparent image as a cursor)?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
I solve this problem much easier:
It appears that the
Cursor
class does not have a "blank" cursor to begin with, so one could define a new "blank" cursor using theToolkit.createCustomCursor
method.Here's one way I've tried which seems to work:
Edit
Regarding the comment about everything inside the
JFrame
ending up without a cursor, it seems that theComponent
s which are contained in theJFrame
will end up inheriting the cursor of the container (theJFrame
), so if it is a requirement to have a certainComponent
have the cursor appear, one would have to manually set the desired cursor.For example, if there is a
JPanel
contained in theJFrame
, then one could set the cursor of thatJPanel
to the system's default using theCursor.getDefaultCursor
method:In the documentation it says that if the image is invalid, then it will be transparent by default so therefore passing an empty image will result in a transparent cursor. But Passing
null
into the method for the image will result in an exception.tl;dr AWT Toolkits are still bugged in 2017'; the proper solution is thus to call
instead.
As per Javadoc page for
createCustomCursor
,It would follow from that that
should do the trick. Sadly, there is a bug related to this case NOT handled by the code, see e.g. http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7150089 (this particular is for MacOS, but by browsing the source you may easily find that there's no checking for 1st param
Image
value validity in any of theToolkit
platform implementations; there'stracker.isErrorAny()
checking, which doesn't do it's job in this case), so passingnull
or invalidImage
simply throws a NPEx.When using the LWJGL under Mac OS you need to do this: