-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMouseDemo.java
More file actions
42 lines (42 loc) · 1.01 KB
/
MouseDemo.java
File metadata and controls
42 lines (42 loc) · 1.01 KB
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
37
38
39
40
41
42
import javafx.application.*;
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.scene.input.*;
import javafx.scene.layout.*;
import javafx.scene.paint.*;
import javafx.event.*;
public class MouseDemo extends Application
{
public static void main(String args[])
{
launch(args);
}
public void start(Stage stage)
{
stage.setTitle("Mouse Events");
Group g=new Group();
Scene s=new Scene(g, 500, 500);
Label l1=new Label("Mouse is Still. Background: Yellow");
s.setFill(Color.YELLOW);
s.setOnMouseClicked(new EventHandler <MouseEvent> ()
{
public void handle(MouseEvent me)
{
s.setFill(Color.YELLOW);
l1.setText("Mouse is Clicked. Background: Yellow");
}
});
s.setOnMouseMoved(new EventHandler <MouseEvent> ()
{
public void handle(MouseEvent me)
{
s.setFill(Color.BLUE);
l1.setText("Mouse is Moved. Background: Blue");
}
});
g.getChildren().add(l1);
stage.setScene(s);
stage.show();
}
}