-
Notifications
You must be signed in to change notification settings - Fork 5
/
P19.java
36 lines (30 loc) · 1.11 KB
/
P19.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
Write a program that displays the color of a circle as red when the mouse button is pressed and as blue when the mouse button is released.
*/
package Practicals;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
public class P19 extends Application
{
@Override
public void start(Stage primaryStage)
{
double width = 450;
double height = 450;
Circle c = new Circle(width / 2, height / 2, Math.min(width, height) / 10, Color.BLUE);
c.setStroke(Color.WHITE);
StackPane pane = new StackPane(c);
primaryStage.setScene(new Scene(pane, width, height));
pane.setOnMousePressed(e -> c.setFill(Color.RED));
pane.setOnMouseReleased(e -> c.setFill(Color.BLUE));
primaryStage.setTitle("Click circle..");
primaryStage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}