Java Code Examples for javafx.scene.layout.Pane#setOnMouseReleased()
The following examples show how to use
javafx.scene.layout.Pane#setOnMouseReleased() .
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: Exercise_15_08b.java From Intro-to-Java-Programming with MIT License | 6 votes |
@Override // Override the start method on the Application class public void start(Stage primaryStage) { // Create a pane Pane pane = new Pane(); // Create and register the handler pane.setOnMousePressed(e -> { pane.getChildren().add(new Text(e.getX(), e.getY(), "(" + e.getX() + ", " + e.getY() + ")")); }); pane.setOnMouseReleased(e -> { pane.getChildren().clear(); }); // Create a scene and place it in the stage Scene scene = new Scene(pane, 200, 200); primaryStage.setTitle("Exercise_15_08b"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example 2
Source File: DoodleTrace.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Apply mouse listener events for desktop platforms. * @param drawSurface The drawing surface to receive mouse input. */ private void applyMouseInput(Pane drawSurface) { // starting initial path drawSurface.setOnMousePressed(mouseEvent -> start.path(mouseEvent.getX(), mouseEvent.getY())); // dragging creates lineTos added to the path drawSurface.setOnMouseDragged(mouseEvent -> draw.path(mouseEvent.getX(), mouseEvent.getY())); // end the path when mouse released event drawSurface.setOnMouseReleased(mouseEvent -> end.path(mouseEvent.getX(), mouseEvent.getY())); }
Example 3
Source File: Exercise_15_27.java From Intro-to-Java-Programming with MIT License | 5 votes |
@Override // Override the start method in the Application class public void start(Stage primaryStage) { // Create a pane Pane pane = new Pane(); // Create a text Text text = new Text("Programing is fun"); pane.getChildren().add(text); // Create a path transition PathTransition pt = new PathTransition(Duration.millis(10000), new Line(-50, 50, 250, 50), text); pt.setCycleCount(Timeline.INDEFINITE); pt.play(); // Start animation // Create and register the handle pane.setOnMousePressed(e -> { pt.pause(); }); pane.setOnMouseReleased(e -> { pt.play(); }); // Create a scene and place it in the stage Scene scene = new Scene(pane, 200, 100); primaryStage.setTitle("Exercise_15_27"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example 4
Source File: Exercise_15_24.java From Intro-to-Java-Programming with MIT License | 4 votes |
@Override // Override the start method in the Application class public void start(Stage primaryStage) { // Create a pane Pane pane = new Pane(); // Create a arc Arc arc = new Arc(100, 50, 75, 25, 0, -180); arc.setFill(Color.WHITE); arc.setStroke(Color.BLACK); // Create a circle Circle circle = new Circle(100, 75, 5); // Place nodes in pane pane.getChildren().addAll(arc, circle); // Create a path transition PathTransition pt = new PathTransition(); pt.setDuration(Duration.millis(4000)); pt.setPath(arc); pt.setNode(circle); pt.setOrientation( PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT); pt.setCycleCount(Timeline.INDEFINITE); pt.setAutoReverse(true); pt.play(); // Start animation // Create and register the handle pane.setOnMousePressed(e -> { pt.pause(); }); pane.setOnMouseReleased(e -> { pt.play(); }); // Create a scene and place it in the stage Scene scene = new Scene(pane, 200, 100); primaryStage.setTitle("Exercise_15_24"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example 5
Source File: Exercise_15_26.java From Intro-to-Java-Programming with MIT License | 4 votes |
@Override // Override the start method in the Application class public void start(Stage primaryStage) { // Create a pane Pane pane = new Pane(); // Create a arc Arc arc = new Arc(100, 50, 75, 25, 0, -180); arc.setFill(Color.WHITE); arc.setStroke(Color.BLACK); // Create a circle Circle ball = new Circle(100, 75, 10); // Place nodes in pane pane.getChildren().addAll(arc, ball); // Create a path transition PathTransition pt = new PathTransition(); pt.setDuration(Duration.millis(4000)); pt.setPath(arc); pt.setNode(ball); pt.setOrientation( PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT); pt.setCycleCount(Timeline.INDEFINITE); pt.setAutoReverse(true); pt.play(); // Start animation // Create a fade transition to ball FadeTransition ft = new FadeTransition(Duration.millis(4000), ball); ft.setFromValue(1.0); ft.setToValue(0.1); ft.setCycleCount(Timeline.INDEFINITE); ft.setAutoReverse(true); ft.play(); // Start animation // Create and register the handle pane.setOnMousePressed(e -> { pt.pause(); ft.pause(); }); pane.setOnMouseReleased(e -> { pt.play(); ft.play(); }); // Create a scene and place it in the stage Scene scene = new Scene(pane, 200, 100); primaryStage.setTitle("Exercise_15_26"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }