-1
我想让光标成为一个圆形,没有填充(像Photoshop中的画笔),但我只找到一种方法将图像放在光标上,没有任何形状。如何将光标更改为JavafX中的圆形?
我想让光标成为一个圆形,没有填充(像Photoshop中的画笔),但我只找到一种方法将图像放在光标上,没有任何形状。如何将光标更改为JavafX中的圆形?
您可以使用节点快照来做到这一点:
// create any shape you want (e.g. circle)
// set fill to null
Circle circle = new Circle(32, null);
// set stroke to required color
circle.setStroke(Color.BLACK);
// this is needed to 'cut' the fill from snapshot
SnapshotParameters sp = new SnapshotParameters();
sp.setFill(Color.TRANSPARENT);
// perform snapshot of the shape into an image
Image image = circle.snapshot(sp, null);
// set cursor from that image
scene.setCursor(new ImageCursor(image, 16, 16));
非常感谢,它的工作:) – Madalina