14
14
15
15
import javax .swing .*;
16
16
import java .awt .*;
17
+ import java .awt .event .WindowEvent ;
18
+ import java .awt .event .WindowListener ;
17
19
import java .io .IOException ;
18
20
import java .util .Map ;
19
21
20
- public class HomePage extends JFrame {
22
+ public class HomePage extends JFrame implements WindowListener {
21
23
22
24
UserLoginResponseModel user ;
23
25
DBGateway gateway ;
@@ -35,7 +37,7 @@ public HomePage(UserLoginResponseModel user) throws IOException {
35
37
IUserDataAccess userDataAccess = new CommonUserDataAccess (DBGateway .getUserPath ());
36
38
DBGateway gateway = new DBGateway (flashcardDataAccess ,
37
39
flashcardSetDataAccess , userDataAccess );
38
-
40
+ this . gateway = gateway ;
39
41
// top bar
40
42
JPanel topBar = new JPanel ();
41
43
topBar .setLayout (new FlowLayout (FlowLayout .CENTER , 20 , 20 ));
@@ -57,10 +59,11 @@ public HomePage(UserLoginResponseModel user) throws IOException {
57
59
FlashcardSetInteractor interactor = new FlashcardSetInteractor (gateway , presenter ,
58
60
setFactory );
59
61
FlashcardSetController controller = new FlashcardSetController (interactor );
60
- new CreationScreen (controller , user );
61
-
62
+ JFrame creationScreen = new CreationScreen (controller , user );
63
+ creationScreen . addWindowListener ( this );
62
64
});
63
65
66
+
64
67
logOff .addActionListener (e -> {
65
68
this .setVisible (false );
66
69
this .dispose ();
@@ -98,7 +101,7 @@ public HomePage(UserLoginResponseModel user) throws IOException {
98
101
}
99
102
100
103
101
- private void refresh (UserLoginResponseModel user ) {
104
+ private void refresh () {
102
105
try {
103
106
UserLoginOutputBoundary presenter = new UserLoginPresenter ();
104
107
UserLoginInputBoundary interactor = new UserLoginInteractor (
@@ -115,4 +118,39 @@ private void refresh(UserLoginResponseModel user) {
115
118
JOptionPane .showMessageDialog (this , e .getMessage ());
116
119
}
117
120
}
121
+
122
+ @ Override
123
+ public void windowOpened (WindowEvent e ) {
124
+
125
+ }
126
+
127
+ @ Override
128
+ public void windowClosing (WindowEvent e ) {
129
+
130
+ }
131
+
132
+ @ Override
133
+ public void windowClosed (WindowEvent e ) {
134
+ refresh ();
135
+ }
136
+
137
+ @ Override
138
+ public void windowIconified (WindowEvent e ) {
139
+
140
+ }
141
+
142
+ @ Override
143
+ public void windowDeiconified (WindowEvent e ) {
144
+
145
+ }
146
+
147
+ @ Override
148
+ public void windowActivated (WindowEvent e ) {
149
+
150
+ }
151
+
152
+ @ Override
153
+ public void windowDeactivated (WindowEvent e ) {
154
+
155
+ }
118
156
}
0 commit comments