Skip to content

Commit 977de3b

Browse files
committed
java doc for home screen
1 parent c711960 commit 977de3b

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

src/main/java/frameworks_and_drivers/screens/HomeScreen.java

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,28 @@
2727
import java.io.IOException;
2828
import java.util.Map;
2929

30-
public class HomeScreen extends Screen implements WindowListener {
30+
/**
31+
* The home page of a user. Includes the list of all their flashcard sets panels including their buttons.
32+
* Also include a top bar with a search, add flashcard set, and log off button.
33+
* Frameworks & Drivers.
34+
* @author Justin Li
35+
*/
3136

37+
public class HomeScreen extends Screen implements WindowListener {
38+
/**
39+
* The logged-in user
40+
*/
3241
UserLoginResponseModel user;
42+
/**
43+
* The gateway object to access the entire database.
44+
*/
3345
DBGateway gateway;
3446

47+
/**
48+
* Creates the home screen.
49+
* @param user the logged-in user.
50+
* @param gateway the gateway object to access the entire database.
51+
*/
3552
public HomeScreen(UserLoginResponseModel user, DBGateway gateway) throws IOException {
3653
super(user.getSignedInUsername() + "'s home page");
3754
this.gateway = gateway;
@@ -43,10 +60,12 @@ public HomeScreen(UserLoginResponseModel user, DBGateway gateway) throws IOExcep
4360
JPanel topBar = new JPanel();
4461
topBar.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 20));
4562

63+
// button creation
4664
JButton searchButton = new JButton("Search");
4765
JButton addFlashcardSetButton = new JButton("Add Flashcard Set");
4866
JButton logOff = new JButton("Log Off");
4967

68+
// action listeners for search, add flashcard set, and log off buttons.
5069
searchButton.addActionListener(e -> {
5170
SearchOutputBoundary presenter = new SearchPresenter();
5271
SearchInteractor interactor = new SearchInteractor(presenter, gateway);
@@ -80,6 +99,7 @@ public HomeScreen(UserLoginResponseModel user, DBGateway gateway) throws IOExcep
8099
topBar.setSize(1000,20);
81100
this.add(topBar);
82101

102+
// adding list of flashcard set data panels to the home screen
83103
Map<Integer, String[]> idsToFlashcardSetData = user.getFlashcardSets();
84104

85105
int numSets = idsToFlashcardSetData.size();
@@ -100,7 +120,10 @@ public HomeScreen(UserLoginResponseModel user, DBGateway gateway) throws IOExcep
100120
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
101121
}
102122

103-
123+
/**
124+
* A function used to refresh the home page by calling the user login again.
125+
* The current home page is dispose and a new home page is created.
126+
*/
104127
public void refresh() {
105128
try {
106129
IFlashcardSetDataAccess flashcardSetDataAccess = new FlashcardSetDataAccess(DBGateway.getFlashcardSetPath());
@@ -124,37 +147,20 @@ public void refresh() {
124147
}
125148

126149
@Override
127-
public void windowOpened(WindowEvent e) {
128-
129-
}
130-
150+
public void windowOpened(WindowEvent e) {}
131151
@Override
132-
public void windowClosing(WindowEvent e) {
133-
134-
}
135-
152+
public void windowClosing(WindowEvent e) {}
136153
@Override
137154
public void windowClosed(WindowEvent e) {
155+
// When a window is closed the page will be refreshed.
138156
refresh();
139157
}
140-
141158
@Override
142-
public void windowIconified(WindowEvent e) {
143-
144-
}
145-
159+
public void windowIconified(WindowEvent e) {}
146160
@Override
147-
public void windowDeiconified(WindowEvent e) {
148-
149-
}
150-
161+
public void windowDeiconified(WindowEvent e) {}
151162
@Override
152-
public void windowActivated(WindowEvent e) {
153-
154-
}
155-
163+
public void windowActivated(WindowEvent e) {}
156164
@Override
157-
public void windowDeactivated(WindowEvent e) {
158-
159-
}
165+
public void windowDeactivated(WindowEvent e) {}
160166
}

0 commit comments

Comments
 (0)