|
22 | 22 | import java.awt.event.WindowEvent;
|
23 | 23 | import java.awt.event.WindowListener;
|
24 | 24 |
|
| 25 | +/** |
| 26 | + * Abstract class that represents a panel for an individual flashcard set. |
| 27 | + * This panel includes buttons for study, edit, test, and delete. |
| 28 | + * Frameworks & Drivers |
| 29 | + * @author Justin Li |
| 30 | + */ |
25 | 31 | public class FlashcardSetDataPanel extends JPanel implements WindowListener {
|
| 32 | + /** |
| 33 | + * The main JFrame that the flashcard set data panel will lie in. |
| 34 | + */ |
26 | 35 | HomeScreen home;
|
| 36 | + |
| 37 | + /** |
| 38 | + * Creates a FlashcardSetDataPanel object that includes the title, description, flashcardSetId, gateway, |
| 39 | + * user, and home. |
| 40 | + * @param title the title of the flashcard set. |
| 41 | + * @param description the description of the flashcard set. |
| 42 | + * @param flashcardSetId the flashcard set id. |
| 43 | + * @param gateway the gateway to reach the flashcard set. |
| 44 | + * @param user the user that owns that flashcard set. |
| 45 | + * @param home the home screen containing the flashcard set panel. |
| 46 | + */ |
27 | 47 | public FlashcardSetDataPanel(String title, String description,
|
28 | 48 | int flashcardSetId, DBGateway gateway,
|
29 | 49 | UserLoginResponseModel user, HomeScreen home) {
|
| 50 | + // Panel Construction |
30 | 51 | Border border = BorderFactory.createTitledBorder(title);
|
31 | 52 |
|
32 |
| - |
33 | 53 | JLabel descriptionLabel = new JLabel(description);
|
34 | 54 | this.add(descriptionLabel);
|
35 | 55 | this.home = home;
|
| 56 | + |
| 57 | + // Button Construction |
36 | 58 | JPanel buttons = new JPanel();
|
37 | 59 |
|
38 | 60 | JButton study = new JButton("Study");
|
39 | 61 | buttons.add(study);
|
| 62 | + |
40 | 63 | JButton test = new JButton("Test");
|
41 | 64 | buttons.add(test);
|
| 65 | + |
42 | 66 | JButton edit = new JButton("Edit");
|
43 | 67 | JButton delete = new JButton("Delete");
|
44 |
| - |
45 |
| - |
46 | 68 | buttons.add(edit);
|
47 | 69 | buttons.add(delete);
|
48 | 70 |
|
| 71 | + // Action listeners for edit, study, test, and delete buttons. |
49 | 72 | edit.addActionListener((e) -> {
|
50 | 73 | EditorMainScreen editor = new EditorMainScreen(flashcardSetId);
|
51 | 74 | editor.addWindowListener(this);
|
@@ -77,39 +100,21 @@ public FlashcardSetDataPanel(String title, String description,
|
77 | 100 | this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
78 | 101 | }
|
79 | 102 |
|
80 |
| - |
81 | 103 | @Override
|
82 |
| - public void windowOpened(WindowEvent e) { |
83 |
| - |
84 |
| - } |
85 |
| - |
| 104 | + public void windowOpened(WindowEvent e) {} |
86 | 105 | @Override
|
87 |
| - public void windowClosing(WindowEvent e) { |
88 |
| - } |
89 |
| - |
| 106 | + public void windowClosing(WindowEvent e) {} |
90 | 107 | @Override
|
91 | 108 | public void windowClosed(WindowEvent e) {
|
| 109 | + // When a window is closed we will refresh the page. |
92 | 110 | home.refresh();
|
93 |
| - |
94 | 111 | }
|
95 |
| - |
96 | 112 | @Override
|
97 |
| - public void windowIconified(WindowEvent e) { |
98 |
| - |
99 |
| - } |
100 |
| - |
| 113 | + public void windowIconified(WindowEvent e) {} |
101 | 114 | @Override
|
102 |
| - public void windowDeiconified(WindowEvent e) { |
103 |
| - |
104 |
| - } |
105 |
| - |
| 115 | + public void windowDeiconified(WindowEvent e) {} |
106 | 116 | @Override
|
107 |
| - public void windowActivated(WindowEvent e) { |
108 |
| - |
109 |
| - } |
110 |
| - |
| 117 | + public void windowActivated(WindowEvent e) {} |
111 | 118 | @Override
|
112 |
| - public void windowDeactivated(WindowEvent e) { |
113 |
| - |
114 |
| - } |
| 119 | + public void windowDeactivated(WindowEvent e) {} |
115 | 120 | }
|
0 commit comments