How to create custom cursor in javaFX?

自闭症网瘾萝莉.ら 提交于 2019-12-01 14:04:49

Checkout the ImageCursor.getBestSize() methods and ImageCursor.getMaximumColors() and see what they return, then try a custom cursor image which matches the best size and maximum colors. Most likely this will be a 32x32 cursor for Windows 8.1.

Here is a quote from the ImageCursor.getBestSize() javadoc:

Gets the supported cursor size that is closest to the specified preferred size. A value of (0,0) is returned if the platform does not support custom cursors.

Note: if an image is used whose dimensions don't match a supported size (as returned by this method), the implementation will resize the image to a supported size. This may result in a loss of quality.

Note: These values can vary between operating systems, graphics cards and screen resolution, but at the time of this writing, a sample Windows Vista machine returned 32x32 for all requested sizes, while sample Mac and Linux machines returned the requested size up to a maximum of 64x64. Applications should provide a 32x32 cursor, which will work well on all platforms, and may optionally wish to provide a 64x64 cursor for those platforms on which it is supported.

Also ensure that the pane that you create is not of zero size and that the pane has been added to a scene so that there is actually a pane area to mouse over and see the cursor change.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!