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