本文整理匯總了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);
});
}