是否有可能(通过方法createCustomCursor()
)创建比 Windows 中预定义的 32x32(例如 64x64 甚至更多)更大的光标?
Toolkit toolkit = Toolkit.getDefaultToolkit();
final Image cursor = toolkit.getImage(getClass().getClassLoader().getResource("images/cursor.png"));
toolkit.getBestCursorSize(64, 64);
Cursor mycursor=toolkit.createCustomCursor(cursor, new Point(0,0), "cursor");
setCursor(mycursor);
我尝试了以下方法:
Cursor emptyCursor = Toolkit.getDefaultToolkit().createCustomCursor(new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB), new Point(0, 0), "empty");
setCursor(emptyCursor);
this.addMouseMotionListener(new MouseMotionListener(){
public void mouseDragged(MouseEvent e) {
}
public void mouseMoved(MouseEvent e) {
xCursor = e.getX();
yCursor = e.getY();
repaint();
//e.consume();
}
});
public void paint( Graphics g ) {
g.drawImage(cursor, xCursor, yCursor, null);
}
但它不起作用,整个 GUI 消失了,光标在每个点都被绘制,所以我必须以某种方式删除它?