本文整理汇总了Java中javafx.scene.Node.setOnMousePressed方法的典型用法代码示例。如果您正苦于以下问题:Java Node.setOnMousePressed方法的具体用法?Java Node.setOnMousePressed怎么用?Java Node.setOnMousePressed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.Node
的用法示例。
在下文中一共展示了Node.setOnMousePressed方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createCell
import javafx.scene.Node; //导入方法依赖的package包/类
@Override
protected Node createCell(T item) {
Node cell = super.createCell(item);
cell.setOnMousePressed(event -> {
if (actionHandler != null) {
actionHandler.accept(item);
}
});
return cell;
}
示例5: makeDraggable
import javafx.scene.Node; //导入方法依赖的package包/类
public void makeDraggable(final Node node) {
node.setOnMousePressed(onMousePressedEventHandler);
node.setOnMouseDragged(onMouseDraggedEventHandler);
node.setOnMouseReleased(onMouseReleasedEventHandler);
}