-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBallPaneController.java
More file actions
43 lines (37 loc) · 883 Bytes
/
Copy pathBallPaneController.java
File metadata and controls
43 lines (37 loc) · 883 Bytes
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
43
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.stage.Stage;
public class BallPaneController extends Application
{
public static void main(String[] args)
{
launch();
}
@Override
public void start(Stage pStage) throws Exception
{
BallPane ballPane = new BallPane();
ballPane.setOnMousePressed(e -> ballPane.pause());
ballPane.setOnMouseReleased(e -> ballPane.play());
ballPane.setOnKeyPressed(e ->
{
if(e.getCode() == KeyCode.UP)
{
ballPane.increaseSpeed();
}
else
{
if(e.getCode() == KeyCode.DOWN)
{
ballPane.decreaseSpeed();
}
}
});
Scene scene = new Scene(ballPane, 250, 150);
pStage.setTitle("Halloween Bouncing Balls");
pStage.setScene(scene);
pStage.show();
ballPane.requestFocus();
}
}