本文整理匯總了Java中javafx.scene.Node.setOnMouseDragged方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.setOnMouseDragged方法的具體用法?Java Node.setOnMouseDragged怎麽用?Java Node.setOnMouseDragged使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.Node
的用法示例。
在下文中一共展示了Node.setOnMouseDragged方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: dragDialogAbleNode
import javafx.scene.Node; //導入方法依賴的package包/類
/**
* 使某個節點具有拖動窗口的能力
* @param node
*/
public void dragDialogAbleNode(Node node){
node.setOnMouseDragged(event -> {
mStage.setX(event.getScreenX() - movex);
mStage.setY(event.getScreenY() - movey);
});
node.setOnMousePressed(event -> {
movex = event.getSceneX();
movey = event.getSceneY();
});
}
示例2: installWindowDragListener
import javafx.scene.Node; //導入方法依賴的package包/類
public static void installWindowDragListener(Node node) {
node.setOnMousePressed(evt -> {
mouseX = evt.getScreenX();
mouseY = evt.getScreenY();
});
node.setOnMouseDragged(evt -> {
double deltaX = evt.getScreenX() - mouseX;
double deltaY = evt.getScreenY() - mouseY;
Window window = node.getScene().getWindow();
window.setX(node.getScene().getWindow().getX() + deltaX);
window.setY(node.getScene().getWindow().getY() + deltaY);
mouseX = evt.getScreenX();
mouseY = evt.getScreenY();
});
}
示例3: MouseTracker
import javafx.scene.Node; //導入方法依賴的package包/類
public MouseTracker(final Node owner) {
owner.setOnMouseMoved(this.onMouseMovedEventHandler);
owner.setOnMouseClicked(this.onMouseClickedEventHandler);
owner.setOnMouseEntered(this.onMouseEnteredEventHandler);
owner.setOnMouseExited(this.onMouseExitedEventHandler);
owner.setOnMouseDragged(this.onMouseDraggedEventHandler);
owner.setOnMousePressed(this.onMousePressedEventHandler);
owner.setOnMouseReleased(this.onMouseReleasedEventHandler);
// Register our own event handler to register mouse placement at all times
owner.addEventFilter(MouseEvent.ANY, event -> {
if(!Double.isNaN(event.getX())) {
xProperty.set(event.getX());
}
if(!Double.isNaN(event.getY())) {
yProperty.set(event.getY());
}
});
}
示例4: makeDraggable
import javafx.scene.Node; //導入方法依賴的package包/類
public void makeDraggable(final Node node) {
node.setOnMousePressed(onMousePressedEventHandler);
node.setOnMouseDragged(onMouseDraggedEventHandler);
node.setOnMouseReleased(onMouseReleasedEventHandler);
}