本文整理汇总了Java中javafx.scene.layout.StackPane.setOnMouseReleased方法的典型用法代码示例。如果您正苦于以下问题:Java StackPane.setOnMouseReleased方法的具体用法?Java StackPane.setOnMouseReleased怎么用?Java StackPane.setOnMouseReleased使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.layout.StackPane
的用法示例。
在下文中一共展示了StackPane.setOnMouseReleased方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ToggleSwitchSkin
import javafx.scene.layout.StackPane; //导入方法依赖的package包/类
/**
* Constructor for all SkinBase instances.
*
* @param control The control for which this Skin should attach to.
*/
protected ToggleSwitchSkin(ToggleSwitch control) {
super(control);
thumb = new StackPane();
thumbArea = new StackPane();
label = new LabeledText(control);
labelContainer = new StackPane();
updateLabel(control);
getChildren().addAll(labelContainer, thumbArea, thumb);
labelContainer.getChildren().addAll(label);
StackPane.setAlignment(label, Pos.CENTER_LEFT);
thumb.getStyleClass().setAll("thumb");
thumbArea.getStyleClass().setAll("thumb-area");
thumbArea.setOnMouseReleased(event -> mousePressedOnToggleSwitch(control));
thumb.setOnMouseReleased(event -> mousePressedOnToggleSwitch(control));
control.selectedProperty().addListener((observable, oldValue, newValue) -> {
if (newValue.booleanValue() != oldValue.booleanValue())
selectedStateChanged();
});
}
示例2: initialize
import javafx.scene.layout.StackPane; //导入方法依赖的package包/类
private void initialize() {
thumb = new StackPane();
thumb.getStyleClass().setAll("thumb");
track = new StackPane();
track.getStyleClass().setAll("track");
fill = new StackPane();
fill.getStyleClass().setAll("fill");
// horizontal = getSkinnable().isVertical();
getChildren().clear();
getChildren().addAll(track, fill, thumb);
setShowTickMarks(getSkinnable().isShowTickMarks(), getSkinnable().isShowTickLabels());
track.setOnMousePressed(me -> mousePressedOnTrack(me));
track.setOnMouseDragged(me -> mouseDraggedOnTrack(me));
fill.setOnMousePressed(me -> mousePressedOnTrack(me));
fill.setOnMouseDragged(me -> mouseDraggedOnTrack(me));
thumb.setOnMousePressed(me -> {
getBehavior().thumbPressed(me, 0.0f);
dragStart = thumb.localToParent(me.getX(), me.getY());
preDragThumbPos = (getSkinnable().getValue() - getSkinnable().getMin()) /
(getSkinnable().getMax() - getSkinnable().getMin());
});
thumb.setOnMouseReleased(me -> getBehavior().thumbReleased(me));
thumb.setOnMouseDragged(me -> {
Point2D cur = thumb.localToParent(me.getX(), me.getY());
double dragPos = (getSkinnable().getOrientation() == Orientation.HORIZONTAL) ?
cur.getX() - dragStart.getX() : -(cur.getY() - dragStart.getY());
getBehavior().thumbDragged(me, preDragThumbPos + dragPos / trackLength);
});
}