本文整理汇总了Java中javafx.scene.shape.Rectangle.setOnMouseClicked方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.setOnMouseClicked方法的具体用法?Java Rectangle.setOnMouseClicked怎么用?Java Rectangle.setOnMouseClicked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.shape.Rectangle
的用法示例。
在下文中一共展示了Rectangle.setOnMouseClicked方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initCommon
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
/**
* Create mouse events and context menu entries.
*/
private void initCommon() {
view.setDurations(concreteSpec.getDurations());
// view.getyAxis().layoutBoundsProperty().addListener(change -> updateAxisExternalPosition());
view.setOnMouseClicked(this::onMouseClicked);
MenuItem xpositiveZoomItem = new MenuItem("Zoom X+");
xpositiveZoomItem.setOnAction(this::onXPositiveZoom);
MenuItem xnegativeZoomItem = new MenuItem("Zoom X-");
xnegativeZoomItem.setOnAction(this::onXNegativeZoom);
view.getContextMenu().getItems().setAll(xpositiveZoomItem, xnegativeZoomItem);
ObservableList<Rectangle> cycleSelectionRectangles = view.getCycleSelectionRectangles();
for (int i = 0; i < cycleSelectionRectangles.size(); i++) {
Rectangle cycleSelectionRectangle = cycleSelectionRectangles.get(i);
int finalCycleIndex = i;
cycleSelectionRectangle.setOnMouseEntered(event -> {
if (activated.get()) {
cycleSelectionRectangle.setOpacity(1);
selection.setRow(concreteSpec.cycleToRowNumber(finalCycleIndex));
selection.setColumn(ioVariable.getName());
}
});
cycleSelectionRectangle.setOnMouseExited(event -> {
if (activated.get()) {
cycleSelectionRectangle.setOpacity(0);
selection.clear();
}
});
cycleSelectionRectangle.setOnMouseClicked(event -> {
if (event.getButton() == MouseButton.PRIMARY) {
selection.fireClickEvent(ioVariable.getName(),
concreteSpec.cycleToRowNumber(finalCycleIndex));
}
});
}
}