-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIngameMenuButtonVersion.java
More file actions
89 lines (74 loc) · 2.25 KB
/
IngameMenuButtonVersion.java
File metadata and controls
89 lines (74 loc) · 2.25 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import java.io.IOException;
import javafx.animation.Interpolator;
import javafx.animation.TranslateTransition;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.util.Duration;
public class IngameMenuButtonVersion extends Application {
public static Stage MenuStage;
@Override
public void start(Stage stage) throws Exception {
// TODO Auto-generated method stub
MenuStage = stage;
stage.setScene(new Scene(createContent()));
stage.show();
}
static Parent createContent() {
Pane root = new Pane();
RoundButton menu = new RoundButton("MENU");
RoundButton exit = new RoundButton("EXIT");
RoundButton print1 = new RoundButton("PAUSE");
RoundButton print2 = new RoundButton("PRINT2");
HBox menuBox = new HBox(10, menu, exit, print1, print2);
root.getChildren().add(menuBox);
return root;
}
public static class RoundButton extends Parent {
RoundButton(String name) {
Button roundButton = new Button(name);
roundButton.setId(name);
roundButton.setOnAction(myHandler);
roundButton.setStyle("-fx-background-radius: 5em; " + "-fx-min-width: 60px; " + "-fx-min-height: 60px; "
+ "-fx-max-width: 60px; " + "-fx-max-height: 60px;");
getChildren().add(roundButton);
}
}
final static EventHandler<ActionEvent> myHandler = new EventHandler<ActionEvent>() {
@Override
public void handle(final ActionEvent event) {
Button x = (Button) event.getSource();
switch (x.getId()) {
case "MENU":
try {
Menu m = new Menu();
Parent mRoot = m.createContent();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
break;
case "PAUSE":
System.out.println(1);
break;
case "PRINT2":
System.out.println(2);
break;
case "EXIT":
System.exit(0);
}
}
};
public static void main(String[] args) {
launch(args);
}
}