-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestEventGUI.java
More file actions
81 lines (60 loc) · 3.54 KB
/
TestEventGUI.java
File metadata and controls
81 lines (60 loc) · 3.54 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
package project3;
import java.lang.String;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.ListView;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.SelectionMode;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import project3.SoccerGamePane;
import project3.BasketBallGamePane;
import project3.ConcertPane;
import project3.OrchestraPane;
import project3.ArtEventPane;
import project3.StatisticsPane;
public class TestEventGUI extends Application {
@Override // javafx.application.Application.start()
public void start(Stage primaryStage) {
String[] titles = {"Soccer Game", "Basketball Game", "Concert", "Orchestra", "Art Event", "Statistics", "Close"};
ListView<String> listView = new ListView<>(FXCollections.observableArrayList(titles));
listView.setPrefSize(150, 400);
listView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
SoccerGamePane soccerGamePane = new SoccerGamePane ();
BasketBallGamePane basketBallGamePane = new BasketBallGamePane();
ConcertPane concertPane = new ConcertPane ();
OrchestraPane orchestraPane = new OrchestraPane ();
ArtEventPane artEventPane = new ArtEventPane ();
StatisticsPane statisticsPane = new StatisticsPane ();
Pane[] displayPanes = {soccerGamePane, basketBallGamePane, concertPane, orchestraPane, artEventPane, statisticsPane};
Pane pane = new Pane();
pane.getChildren().add(displayPanes[0]);
pane.setPadding (new Insets(5, 5, 5, 5));
BorderPane borderPane = new BorderPane();
borderPane.setLeft (new ScrollPane(listView));
borderPane.setCenter(pane);
listView.getSelectionModel().selectedItemProperty().addListener(ov -> {
pane.getChildren().clear();
for (int i: listView.getSelectionModel().getSelectedIndices()) {
if (i == displayPanes.length) primaryStage.close();
else {
if (displayPanes[i] instanceof ArtEventPane ) artEventPane .clear();
else if (displayPanes[i] instanceof SoccerGamePane ) soccerGamePane .clear();
else if (displayPanes[i] instanceof BasketBallGamePane) basketBallGamePane.clear();
else if (displayPanes[i] instanceof ConcertPane ) concertPane .clear();
else if (displayPanes[i] instanceof OrchestraPane ) orchestraPane .clear();
statisticsPane .clear();
pane.getChildren().add(displayPanes[i]);
} // if
} // for
}); // addListener
Scene scene = new Scene(borderPane, 450, 170);
primaryStage.setScene(scene); // place the scene in the stage
primaryStage.setTitle("TestEventGUI"); // set the stage title
primaryStage.show(); // display the stage
} // start()
public static void main(String[] args) {Application.launch(args);}
} // TestEventGUI