-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPaneOrganizer.java
38 lines (32 loc) · 1.09 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
package alienMover;
import javafx.event.ActionEvent;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
public class PaneOrganizer {
private BorderPane root;
private Alien alien;
public PaneOrganizer() {
this.root = new BorderPane();
Pane alienPane = new Pane();
this.root.setCenter(alienPane);
HBox buttonPane = new HBox();
this.root.setBottom(buttonPane);
this.alien = new Alien(alienPane);
this.setUpButtons(buttonPane);
}
private void setUpButtons(HBox buttonPane) {
Button b1 = new Button("Move Left!");
Button b2 = new Button("Move Right!");
buttonPane.getChildren().addAll(b1, b2);
buttonPane.setSpacing(Constants.BUTTON_SPACING);
buttonPane.setAlignment(Pos.CENTER);
b1.setOnAction((ActionEvent e) -> this.alien.moveLeft());
b2.setOnAction((ActionEvent e) -> this.alien.moveRight());
}
public Pane getRoot() {
return this.root;
}
}