- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.java
More file actions
Latest commit
123 lines (106 loc) · 4.19 KB
/
Copy pathMainWindow.java
File metadata and controls
123 lines (106 loc) · 4.19 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
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
importjavax.swing.*;
importjava.awt.*; // FlowLayout
// tested
publicclassMainWindowextendsJFrame {
// widgets
JButtonbutton;
// menus
JMenuBarmenuBar;
JMenufileMenu;
JMenuItemdownloadBracketItem;
JMenuItemconvertHTMLToDbItem;
JMenuItemloadBracketItem;
JMenueditMenu;
JMenuItempreferencesItem;
JMenupredictionsMenu;
JMenuItemsavePredictionsItem;
JMenuItemloadPredictionsItem;
MainWindow() {
super(); // invoke parent constructor
// widgets
this.button = newJButton("Click");
this.button.setBounds(130, 100, 100, 100); // x, y, width, height
this.add(button);
// menu items
this.downloadBracketItem = newJMenuItem();
this.downloadBracketItem.setText("Download Bracket");
this.convertHTMLToDbItem = newJMenuItem();
this.convertHTMLToDbItem.setText("Convert HTML to DB");
this.loadBracketItem = newJMenuItem();
this.loadBracketItem.setText("Load Bracket");
this.preferencesItem = newJMenuItem();
this.preferencesItem.setText("Preferences");
this.savePredictionsItem = newJMenuItem();
this.savePredictionsItem.setText("Save Predictions");
this.loadPredictionsItem = newJMenuItem();
this.loadPredictionsItem.setText("Load Predictions");
// event handlers
this.downloadBracketItem.addActionListener((event) -> this.onDownloadBracket());
this.convertHTMLToDbItem.addActionListener((event) -> this.onConvertHTMLToDb());
this.loadBracketItem.addActionListener((event) -> this.onLoadBracket());
this.preferencesItem.addActionListener((event) -> this.onPreferences());
this.savePredictionsItem.addActionListener((event) -> this.onSavePredictions());
this.loadPredictionsItem.addActionListener((event) -> this.onLoadPredictions());
// menus
this.fileMenu = newJMenu();
this.fileMenu.setText("File");
this.fileMenu.add(this.downloadBracketItem);
this.fileMenu.add(this.convertHTMLToDbItem);
this.fileMenu.add(this.loadBracketItem);
this.editMenu = newJMenu();
this.editMenu.setText("Edit");
this.editMenu.add(this.preferencesItem);
this.predictionsMenu = newJMenu();
this.predictionsMenu.setText("Predictions");
this.predictionsMenu.add(this.savePredictionsItem);
this.predictionsMenu.add(this.loadPredictionsItem);
// menu bar
this.menuBar = newJMenuBar();
this.menuBar.add(this.fileMenu);
this.menuBar.add(this.editMenu);
this.menuBar.add(this.predictionsMenu);
// frame
ImageIconlogo = newImageIcon("images/icon.png");
this.setIconImage(logo.getImage());
this.setSize(400,500);
this.setLayout(null);
this.setTitle("Fantasy Tennis");
this.setJMenuBar(this.menuBar);
}
// tested
voidonDownloadBracket() {
DownloadDialog.downloadArchive(2019, "out");
String[] downloadOptions = DownloadDialog.getDownloadOptions("tmp");
DownloadDialogdialog = newDownloadDialog(downloadOptions, "out.html");
dialog.setVisible(true);
}
// not tested
voidonConvertHTMLToDb() {
ConvertHTMLDialogdialog = newConvertHTMLDialog();
dialog.setVisible(true);
}
// tested
voidonLoadBracket() {
LoadBracketDialogdialog = newLoadBracketDialog();
dialog.setVisible(true);
}
// not tested
voidonPreferences() {
PreferencesDialogdialog = newPreferencesDialog();
dialog.setVisible(true);
}
// not tested
voidonSavePredictions() {
SavePredictionsDialogdialog = newSavePredictionsDialog("out.db");
dialog.setVisible(true);
}
// tested
voidonLoadPredictions() {
LoadPredictionsDialogdialog = newLoadPredictionsDialog();
dialog.setVisible(true);
}
publicstaticvoidmain(String[] args) {
MainWindowmainWindow = newMainWindow();
mainWindow.setVisible(true);
}
}