-
Notifications
You must be signed in to change notification settings - Fork 0
/
PaneOrganizer.java
73 lines (64 loc) · 2.22 KB
/
PaneOrganizer.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
package basicGUI;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
// PaneOrganizer sets up the GUI
public class PaneOrganizer {
// Creates the BorderPane which will be the root
private BorderPane _root;
public PaneOrganizer() {
this.setupRoot();
}
// setupRoot instantiates the BorderPane _root and calls setup methods for its contents
private void setupRoot() {
_root = new BorderPane();
// Sets each object in a section of the BorderPane
_root.setTop(this.setupHBox());
_root.setLeft(this.setupVBox());
_root.setCenter(this.setupLabel());
}
// getRoot returns the BorderPane _root so it can be used to setup the scene
public BorderPane getRoot() {
return _root;
}
// setupHBox creates an HBox
private HBox setupHBox() {
// Sets up HBox and its separation
HBox hbox = new HBox(10);
hbox.setPrefHeight(50);
// Sets the alignment of HBox within its section of the BorderPane
hbox.setAlignment(Pos.BOTTOM_CENTER);
hbox.setStyle("-fx-background-color: blue;");
Button topButton1 = new Button("Top Button 1");
Button topButton2 = new Button("Top Button 2");
Button topButton3 = new Button("Top Button 3");
hbox.getChildren().addAll(topButton1, topButton2, topButton3);
return hbox;
}
// setupVBox creates a VBox
private VBox setupVBox() {
// Sets up VBox and its separation
VBox vbox = new VBox(20);
vbox.setPrefWidth(95);
// Sets the alignment of VBox within its section of the BorderPane
vbox.setAlignment(Pos.CENTER_LEFT);
vbox.setStyle("-fx-background-color: black;");
Button leftButton1 = new Button("Left Button 1");
Button leftButton2 = new Button("Left Button 2");
Button leftButton3 = new Button("Left Button 3");
vbox.getChildren().addAll(leftButton1, leftButton2, leftButton3);
return vbox;
}
// setupLabel creates a Label
private Label setupLabel() {
Label label = new Label("Hello, I'm a red Label");
// Sets alignment of label within its section of the BorderPane
label.setAlignment(Pos.CENTER);
// Sets background color behind the label
label.setStyle("-fx-background-color: red;");
return label;
}
}