本文整理汇总了Java中javafx.scene.Node.setOnMouseClicked方法的典型用法代码示例。如果您正苦于以下问题:Java Node.setOnMouseClicked方法的具体用法?Java Node.setOnMouseClicked怎么用?Java Node.setOnMouseClicked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.Node
的用法示例。
在下文中一共展示了Node.setOnMouseClicked方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populateMonthPane
import javafx.scene.Node; //导入方法依赖的package包/类
/**
* Creates and positions every node onto the GridPane for the given month and year.
* Uses 7 (weekdays) columns and (max.) 6 rows (weeks). The rows and columns are created on fly or
* are reused.
*
* @param monthPane The GradPane that is used for populating the DayNodes.
* @param month The month that should be displayed.
* @param year The year that should be displayed.
*/
private void populateMonthPane(GridPane monthPane, Month month, int year) {
monthPane.getChildren().clear();
int currentRow = 0;
for(LocalDate d = LocalDate.of(year, month, 1);
d.getMonthValue() == month.getValue();
d = d.plusDays(1)) {
Node dayNode = renderDayItem(d);
final LocalDate currentDate = d;
dayNode.setOnMouseClicked(event -> selectedDateProperty.set(currentDate));
int column = d.getDayOfWeek().getValue();
monthPane.add(dayNode, column, currentRow);
if(column == 7) {
currentRow++;
}
}
}
示例2: onViewCreated
import javafx.scene.Node; //导入方法依赖的package包/类
@Override
protected void onViewCreated() {
if (root != null) {
Node okBtn = root.lookup("#ok");
if (okBtn != null) {
okBtn.setOnMouseClicked(event -> this.onOk());
}
Node cancelBtn = root.lookup("#cancel");
if (cancelBtn != null) {
cancelBtn.setOnMouseClicked(event -> this.onCancel());
}
} else {
Logger.error(this.getClass().getName(), getClass().getName() + " do not set the root to your fxml!");
}
}
示例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: getNodeForDrawableAddNew
import javafx.scene.Node; //导入方法依赖的package包/类
private Node getNodeForDrawableAddNew (Drawable drawn) {
if (myDrawNodeMap.containsKey(drawn)) {
return myDrawNodeMap.get(drawn);
}
else {
Node node = drawn.getDrawer().getVisualRepresentation(myFactory);
node.setOnMouseClicked(e -> mySpriteDisplay.populate(drawn));
myDrawNodeMap.put(drawn, node);
add(node);
return node;
}
}
示例5: createRightClickMenu
import javafx.scene.Node; //导入方法依赖的package包/类
/**
* Sets the sprite action menu on right click
*
* @param node
*/
private void createRightClickMenu (Node node) {
node.setOnMouseClicked(event -> {
if (event.getButton() == MouseButton.SECONDARY) {
spriteActionsMenu(levelView.getPane()).show(node,
event.getScreenX(),
event.getScreenY());
}
});
}
示例6: setOnDoubleClick
import javafx.scene.Node; //导入方法依赖的package包/类
/**
* Convenience setter for double-click events. The handler that you pass to this function doesn't have to
* explicitly check that the event is a double click (that's the convenience).
*
* @param node Node that will respond to a double-click
* @param doubleClickHandler Your double-click handler.
*/
public static void setOnDoubleClick(Node node, EventHandler<? super MouseEvent> doubleClickHandler) {
node.setOnMouseClicked(event -> {
if(event.getButton().equals(MouseButton.PRIMARY) && event.getClickCount() == 2) {
doubleClickHandler.handle(event);
}
});
}
示例7: generateDialog
import javafx.scene.Node; //导入方法依赖的package包/类
private void generateDialog(GoogleService t) {
Dialog<ArrayList<String>> dialog = new Dialog<>();
dialog.setWidth(300);
dialog.setTitle("Sync with Google Drive");
dialog.setHeaderText("Google Drive Sync");
ButtonType loginButtonType = new ButtonType("View", ButtonData.OK_DONE);
ButtonType cancelButtonType = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE);
dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, cancelButtonType);
VBox vbox = new VBox();
vbox.setSpacing(10);
vbox.setAlignment(Pos.CENTER);
vbox.setPrefWidth(dialog.getWidth());
vbox.getChildren().add(new Label("Wait, sync is in progress."));
ProgressBar p = new ProgressBar();
p.setPrefWidth(300);
vbox.getChildren().add(p);
// Enable/Disable login button depending on whether a username was entered.
Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
loginButton.setDisable(true);
Node cancelButton = dialog.getDialogPane().lookupButton(cancelButtonType);
cancelButton.setOnMouseClicked(event ->{
t.cancel();
DownloadFiles.getInstance().stop();
});
t.setOnCancelled(event ->{
System.out.println("Downloading cancelled.");
t.cancel();
});
t.setOnSucceeded(success_evt ->{
System.out.println("Succeded.");
loginButton.setDisable(false);
cancelButton.setDisable(true);
});
dialog.getDialogPane().setContent(vbox);
dialog.setResultConverter(dialogButton -> {
if (dialogButton == loginButtonType) {
try {
model_man.listFromGoogleTable();
} catch (IOException ex) {
Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex);
}
return images;
}
return null;
});
Optional<ArrayList<String>> result = dialog.showAndWait();
result.ifPresent(usernamePassword -> {
ObservableList list = FXCollections.observableArrayList(images);
image_list.setCellFactory(new CallbackImpl());
image_list.getItems().clear();
image_list.refresh();
image_list.setItems(list);
items_count.setText(String.valueOf(images.size()));
});
}
示例8: createGameDisp
import javafx.scene.Node; //导入方法依赖的package包/类
private Node createGameDisp (File file) throws LoadErrorException {
IGame game = new GameReader().readFile(file);
Node poster = new GamePosterFactory().createGamePoster(game);
poster.setOnMouseClicked(event -> playOnDoubleClick(event, game));
return poster;
}
示例9: viewCustom
import javafx.scene.Node; //导入方法依赖的package包/类
@Override
public void viewCustom(String title, String headerText, String content) {
if(t != null){
Dialog<ArrayList<String>> dialog = new Dialog<>();
dialog.setWidth(300);
dialog.setTitle(title);
dialog.setHeaderText(headerText);
ButtonType loginButtonType = new ButtonType("OK", ButtonBar.ButtonData.OK_DONE);
ButtonType cancelButtonType = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE);
dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, cancelButtonType);
VBox vbox = new VBox();
vbox.setSpacing(10);
vbox.setAlignment(Pos.CENTER);
vbox.setPrefWidth(dialog.getWidth());
vbox.getChildren().add(new Label(content));
ProgressBar p = new ProgressBar();
p.setPrefWidth(300);
vbox.getChildren().add(p);
// Enable/Disable login button depending on whether a username was entered.
Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
loginButton.setDisable(true);
Node cancelButton = dialog.getDialogPane().lookupButton(cancelButtonType);
cancelButton.setOnMouseClicked(event ->{
t.cancel();
});
t.setOnCancelled(event ->{
t.cancel();
});
t.setOnSucceeded(success_evt ->{
System.out.println("Succeded.");
loginButton.setDisable(false);
cancelButton.setDisable(true);
});
dialog.getDialogPane().setContent(vbox);
dialog.getDialogPane().getStylesheets().add("/styles/Styles.css");
dialog.setResultConverter(dialogButton -> {
if (dialogButton == loginButtonType) {
}
return null;
});
Optional<ArrayList<String>> result = dialog.showAndWait();
result.ifPresent(usernamePassword -> {
});
}
}
示例10: createTopBar
import javafx.scene.Node; //导入方法依赖的package包/类
public HBox createTopBar()
{
HBox hbox = new HBox();
hbox.setPadding(new Insets(15, 15, 15, 15));
hbox.setSpacing(10);
hbox.setStyle("-fx-background-color: lightsteelblue;");
ObservableList<Node> buttons = hbox.getChildren();
Set<Node> buttonEffectsSet = new HashSet<>();
Node runButton = new ImageView("toolbar_run.png");
runButton.setOnMouseClicked((event) -> {
// TODO: Attach to Backend
});
buttons.add(runButton);
buttonEffectsSet.add(runButton);
Node stepButton = new ImageView("toolbar_step.png");
runButton.setOnMouseClicked((event) -> {
// TODO: Attach to Backend
});
buttons.add(stepButton);
buttonEffectsSet.add(stepButton);
Node resetButton = new ImageView("toolbar_reset.png");
runButton.setOnMouseClicked((event) -> {
// TODO: Attach to Backend
});
buttons.add(resetButton);
buttonEffectsSet.add(resetButton);
buttonEffectsSet.forEach(EmulationWindow::setButtonEffect);
Label cycleLabel = new Label();
cycleLabel.setText("Cycle: ");
cycleLabel.setFont(Font.font("Arial", FontWeight.NORMAL, 18));
buttons.add(cycleLabel);
Label cycleLabelCount = new Label();
cycleLabelCount.setText("0");
cycleLabelCount.setFont(Font.font("Arial", FontWeight.NORMAL, 18));
buttons.add(cycleLabelCount);
Label stepLabel = new Label();
stepLabel.setText("Step: ");
stepLabel.setFont(Font.font("Arial", FontWeight.NORMAL, 18));
buttons.add(stepLabel);
Label stepLabelCount = new Label();
stepLabelCount.setText("0");
stepLabelCount.setFont(Font.font("Arial", FontWeight.NORMAL, 18));
buttons.add(stepLabelCount);
Label simModeState = new Label();
simModeState.setText("Sim Mode");
simModeState.setFont(Font.font("Arial", FontWeight.NORMAL, 16));
buttons.add(simModeState);
Node simModeImage = new ImageView("sim_mode_on.png");
buttons.add(simModeImage);
return hbox;
}
示例11: addEmojiNodeListener
import javafx.scene.Node; //导入方法依赖的package包/类
/**
* 创建emoji节点stackpane,并给其添加事件监听器
* @param emoji
* @return
*/
private Node addEmojiNodeListener(Emoji emoji) {
// 是否需要光标设置
Node stackPane = EmojiDisplayer.createEmojiNode(emoji, 32, 3);
if (stackPane instanceof StackPane) {
// 设置光标手势
stackPane.setCursor(Cursor.HAND);
ScaleTransition st = new ScaleTransition(Duration.millis(90), stackPane);
// 设置提示
Tooltip tooltip = new Tooltip(emoji.getShortname());
Tooltip.install(stackPane, tooltip);
// 设置光标的触发事件
stackPane.setOnMouseEntered(e -> {
// stackPane.setStyle("-fx-background-color: #a6a6a6;
// -fx-background-radius: 3;");
stackPane.setEffect(new DropShadow());
st.setToX(1.2);
st.setToY(1.2);
st.playFromStart();
if (searchTextField.getText().isEmpty())
searchTextField.setPromptText(emoji.getShortname());
});
// 设置光标的离开事件
stackPane.setOnMouseExited(e -> {
// stackPane.setStyle("");
stackPane.setEffect(null);
st.setToX(1.);
st.setToY(1.);
st.playFromStart();
});
// 设置光标的点击事件
stackPane.setOnMouseClicked(e -> {
// 获得emoji简称
String shortname = emoji.getShortname();
chatController.getMessageBoxTextArea().appendText(shortname);
// 关闭emoji选择器
if (getLocalStage().isShowing()) {
closeLocalStage();
}
});
}
return stackPane;
}