自定义Cursor java [英] Custom Cursor java
问题描述
所以我的问题是,在星期六我做了一个自定义框架在Java和我做了,所以用户可以移动框架。我得到了工作。现在我的问题是,我有一个标签,给予我的用户移动框架的能力,我想知道如何使它当用户点击或鼠标在标签,它显示一个光标,我有制作。
在你的MouseListener中,你可以使用:
event.getComponent()。setCursor(...);
阅读Cursor API了解更多信息。您可以使用getPredefinedCursor()方法。
mousePressed()方法将设置游标。
编辑:
p>要使用自定义游标,基本代码是: Cursor custom = Toolkit.getDefaultToolkit()createCustomCursor 。);
,并提供要用于光标的图像。
So my issue is that on Saturday I made a custom frame in Java and I made it so the user can move the frame. I got that working. Now my question is that I have a label which gives my users the ability to move the frame around and I was wondering how would I make it so when the users is clicking or the mouse is in the label, it shows a Cursor that I have made. I was just wondering what code would I use for this.
In your MouseListener you can use:
event.getComponent().setCursor(...);
Read the Cursor API for more information. You can use the getPredefinedCursor() method.
The mousePressed() method would set the cursor. Then in the mouseReleased() method you would set the cursor to null to restore the default cursor.
Edit:
To use a custom cursor the basic code would be:
Cursor custom = Toolkit.getDefaultToolkit().createCustomCursor(...);
and you provide the image to use for the Cursor.
这篇关于自定义Cursor java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!