【发布时间】:2015-03-24 02:56:58
【问题描述】:
我正在开发一个应用程序,我可以在其中将 ImageView 拖放到场景的任何位置。当我运行该应用程序时,它在我第一次拖动 ImageView 时运行良好,但在我释放它后没有响应。
这是我的 FXML 控制器:
@FXML
private ImageView card;
@FXML
private void handleCardMousePressed(MouseEvent event) {
System.out.println("Drag Entered");
DropShadow dropShadow=new DropShadow();
dropShadow.setColor(Color.rgb(18,139,237));
dropShadow.setSpread(.48);
card.setEffect(dropShadow);
card.setMouseTransparent(true);
event.consume();
}
@FXML
private void handleCardMouseDragged(MouseEvent event){
System.out.println("In Drag");
card.setLayoutX(event.getSceneX());
card.setLayoutY(event.getSceneY());
event.consume();
}
@FXML
private void handleCardMouseReleased(MouseEvent event){
System.out.println("Exit Drag");
card.setEffect(null);
event.consume();
}
【问题讨论】:
标签: javafx event-handling mouseevent fxml