-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlackRockApp.java
168 lines (138 loc) · 5.65 KB
/
BlackRockApp.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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
package BlackRock;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;
import javafx.scene.text.Font;
import java.io.FileInputStream;
public class BlackRockApp extends Application{
private Stage window;
private boolean welcomeHasBeenViewed = false;
private Scene sceneChoose;
private Scene scenePage;
private VBox layout = new VBox(100);
private Button buttonLearn = new Button("Learn");
private Button buttonTrain = new Button("Train");
private Button buttonInvest = new Button("Invest");
@Override
public void start(Stage stage) throws Exception {
window = stage;
window.setHeight(1000);
window.setWidth(500);
setButtonsAndLabels();
layout = getLayout();
layout.getChildren().addAll(buttonLearn, buttonTrain, buttonInvest);
layout.setSpacing(200);
sceneChoose = new Scene(layout, 381, 700);
buttonLearn.setOnAction(e -> startPage("Learn"));
buttonTrain.setOnAction(e -> startPage("Train"));
buttonInvest.setOnAction(e -> startPage("Invest"));
if(!welcomeHasBeenViewed) {
Scene sceneWelcome = new Scene(getWelcomeePage(), 381, 700);
window.setScene(sceneWelcome);
welcomeHasBeenViewed = true;
} else {
window.setScene(sceneChoose);
}
window.setResizable(false);
window.show();
}
private void setButtonsAndLabels(){
buttonLearn.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT,
CornerRadii.EMPTY, Insets.EMPTY)));
buttonLearn.setTextFill(Color.BLACK);
buttonLearn.setScaleX(6);
buttonLearn.setScaleY(6);
buttonLearn.setTranslateX(15);
buttonLearn.setFont(Font.font("Avenir", FontWeight.BOLD, 20));
buttonTrain.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT,
CornerRadii.EMPTY, Insets.EMPTY)));
buttonTrain.setTextFill(Color.BLACK);
buttonTrain.setScaleX(6);
buttonTrain.setScaleY(6);
buttonTrain.setTranslateX(15);
buttonTrain.setFont(Font.font("Avenir", FontWeight.BOLD, 20));
buttonInvest.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT,
CornerRadii.EMPTY, Insets.EMPTY)));
buttonInvest.setTextFill(Color.BLACK);
buttonInvest.setScaleX(6);
buttonInvest.setScaleY(6);
buttonInvest.setTranslateX(15);
buttonInvest.setFont(Font.font("Avenir", FontWeight.BOLD, 20));
}
private VBox getWelcomeePage(){
VBox welcome = new VBox();
Button onward = new Button("");
onward.setPrefSize(400,800);
onward.setOnAction(e -> startPage("choose"));
onward.setAlignment(Pos.CENTER);
onward.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT,
CornerRadii.EMPTY, Insets.EMPTY)));
try{
FileInputStream input = new FileInputStream("/Users/rachelbick/Documents/Hackathon-BlackRockApp/src/BlackRock/br_pages3.001.jpg");
Image menuBackgroundImage = new Image(input);
BackgroundImage backgroundImage = new BackgroundImage(menuBackgroundImage,
BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT,BackgroundPosition.CENTER,
BackgroundSize.DEFAULT);
welcome.setBackground(new Background(backgroundImage));
}catch(java.io.FileNotFoundException e){
System.out.println(e);
}
welcome.getChildren().add(onward);
return welcome;
}
private VBox getLayout(){
try{
FileInputStream input = new FileInputStream("/Users/rachelbick/Documents/Hackathon-BlackRockApp/src/BlackRock/latest 1.002.jpg");
Image menuBackgroundImage = new Image(input);
BackgroundImage backgroundImage = new BackgroundImage(menuBackgroundImage,
BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT,BackgroundPosition.CENTER,
BackgroundSize.DEFAULT);
layout.setBackground(new Background(backgroundImage));
layout.setAlignment(Pos.CENTER);
layout.setSpacing(0.0);
}catch (java.io.FileNotFoundException e){
System.out.println(e);
System.out.println("problem accessing image");
System.exit(1);
}
return layout;
}
EventHandler<PageEvent> pageEvent = event -> {
leavePage();
};
private void leavePage(){
scenePage.removeEventHandler(PageEvent.LEAVE_PAGE, pageEvent);
scenePage = null;
window.setScene(sceneChoose);
}
private void startPage(String page){
if(page.equals("choose")){
scenePage = sceneChoose;
}
else if(page.equals("Learn")){
window.setTitle("Learn");
Learn learn = new Learn();
scenePage = learn.getLearnScene();
}
else if(page.equals("Train")){
window.setTitle("Train");
Train train = new Train();
scenePage = train.getTrainScene();
}
else if(page.equals("Invest")){
window.setTitle("Invest");
Invest invest = new Invest();
scenePage = invest.getInvestScene();
}
scenePage.addEventHandler(PageEvent.LEAVE_PAGE, pageEvent);
window.setScene(scenePage);
}
}