我正在创建一个简单的javafx应用程序.我只是想在两个同心圆之间提供的区域内剪切图像,这会改变鼠标移动时的中心坐标,cliped对象最初出现在定义的位置,但它不响应鼠标移动.请告诉我我做错了什么.
我的代码是:
public DoubleProperty xCordinate;
public DoubleProperty yCordinate;
@Override
public void start(Stage primaryStage) {
Group root = new Group();
Image image = new Image(MyClass.class
.getResource("Water lilies.jpg").toExternalForm());
Scene scene = new Scene(root, image.getWidth(), image.getHeight(),
Color.WHITE);
ImageView view = new ImageView();
view.setImage(image);
xCordinate = new SimpleDoubleProperty(100.0f);
yCordinate = new SimpleDoubleProperty(100.0f);
scene.setOnMouseMoved(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
xCordinate.set(event.getX());
yCordinate.set(event.getY());
System.out.println("xCordinate " + xCordinate + " yCordinate "
+ yCordinate);
}
});
Circle c1 = new Circle();
c1.centerXProperty().bind(xCordinate);
c1.centerYProperty().bind(yCordinate);
c1.setRadius(50.0f);
Circle …Run Code Online (Sandbox Code Playgroud)