Java Code Examples for javafx.scene.Node#setOnMouseClicked()
The following examples show how to use
javafx.scene.Node#setOnMouseClicked() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TargetEditorController.java From ShootOFF with GNU General Public License v3.0 | 6 votes |
public void init(Image backgroundImg, TargetListener targetListener, File targetFile) { init(backgroundImg, targetListener); final Optional<TargetComponents> targetComponents = TargetIO.loadTarget(targetFile); if (targetComponents.isPresent()) { final TargetComponents tc = targetComponents.get(); targetTags.putAll(tc.getTargetTags()); targetRegions.addAll(tc.getTargetGroup().getChildren()); for (final Node region : tc.getTargetGroup().getChildren()) { region.setOnMouseClicked((e) -> { regionClicked(e); }); region.setOnKeyPressed((e) -> { regionKeyPressed(e); }); } canvasPane.getChildren().addAll(tc.getTargetGroup().getChildren()); } }
Example 2
Source File: DragResizerUtil.java From chart-fx with Apache License 2.0 | 5 votes |
protected DragResizerUtil(Node node, OnDragResizeEventListener listener) { this.node = node; this.listener = listener != null ? listener : DEFAULT_LISTENER; if (node == null) { throw new IllegalArgumentException("node must not be null"); } node.setOnMousePressed(this::mousePressed); node.setOnMouseDragged(this::mouseDragged); node.setOnMouseMoved(this::mouseOver); node.setOnMouseReleased(this::mouseReleased); node.setOnMouseClicked(this::resetNodeSize); }
Example 3
Source File: EffectUtilities.java From mars-sim with GNU General Public License v3.0 | 5 votes |
/** configures the node to fade when it is clicked on performed the onFinished handler when the fade is complete */ public static void fadeOnClick(final Node node, final EventHandler<ActionEvent> onFinished) { node.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { node.setMouseTransparent(true); FadeTransition fade = new FadeTransition(Duration.seconds(1.2), node); fade.setOnFinished(onFinished); fade.setFromValue(1); fade.setToValue(0); fade.play(); } }); }
Example 4
Source File: EffectUtilities.java From mars-sim with GNU General Public License v3.0 | 5 votes |
/** configures the node to fade when it is clicked on performed the onFinished handler when the fade is complete */ public static void fadeOnClick(final Node node, final EventHandler<ActionEvent> onFinished) { node.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { node.setMouseTransparent(true); FadeTransition fade = new FadeTransition(Duration.seconds(1.2), node); fade.setOnFinished(onFinished); fade.setFromValue(1); fade.setToValue(0); fade.play(); } }); }
Example 5
Source File: EmojiSelectorController.java From ChatRoom-JavaFX with Apache License 2.0 | 4 votes |
/** * 创建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; }
Example 6
Source File: TargetEditorController.java From ShootOFF with GNU General Public License v3.0 | 4 votes |
@FXML public void regionDropped(MouseEvent event) { if (freeformButton.isSelected() && event.getButton().equals(MouseButton.PRIMARY)) { drawPolygon(event); } else if (freeformButton.isSelected() && event.getButton().equals(MouseButton.SECONDARY)) { drawShape(); clearFreeformState(true); } if (!cursorRegion.isPresent() || cursorButton.isSelected()) return; final Node selected = cursorRegion.get(); targetRegions.add(selected); selected.setOnMouseClicked((e) -> { regionClicked(e); }); selected.setOnKeyPressed((e) -> { regionKeyPressed(e); }); if (((TargetRegion) selected).getType() == RegionType.IMAGE) { final ImageRegion droppedImage = (ImageRegion) selected; // If the new image region has an animation, play it once if (droppedImage.getAnimation().isPresent()) { final SpriteAnimation animation = droppedImage.getAnimation().get(); animation.setCycleCount(1); animation.setOnFinished((e) -> { animation.reset(); animation.setOnFinished(null); }); animation.play(); } drawImage(droppedImage.getImageFile()); } else { drawShape(); } }
Example 7
Source File: MilestonePickerDialog.java From HubTurbo with GNU Lesser General Public License v3.0 | 4 votes |
private Node setMouseClickForNode(Node node, String milestoneName) { node.setOnMouseClicked(e -> handleMouseClick(milestoneName)); return node; }
Example 8
Source File: AssigneePickerDialog.java From HubTurbo with GNU Lesser General Public License v3.0 | 4 votes |
private Node setMouseClickForNode(Node node, String username) { node.setOnMouseClicked(e -> handleMouseClick(username)); return node; }
Example 9
Source File: LabelPickerDialog.java From HubTurbo with GNU Lesser General Public License v3.0 | 4 votes |
/** * @param label * @return Node from label after registering mouse handler */ private final Node getPickerLabelNode(PickerLabel label) { Node node = label.getNode(); node.setOnMouseClicked(e -> handleLabelClick(label.getFullName())); return node; }