-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuiClass.java
More file actions
52 lines (47 loc) · 1.44 KB
/
GuiClass.java
File metadata and controls
52 lines (47 loc) · 1.44 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
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.BorderFactory;
import java.awt.BorderLayout;
/**
* Setup class (parent) for all GUI classes; cannot be instantiated
*/
public abstract class GuiClass extends JFrame {
/**
* subject this GUI sends data to in the subject observer model
*/
private final SubjectInterface subject;
/**
* panel this GUI displays widgets on
*/
private final JPanel panel;
/**
* Basic constructor for GUIs
*
* @param subject subject this GUI sends data to in the subject observer model; cannot be null
*/
public GuiClass(SubjectInterface subject) {
if (subject == null) throw new IllegalArgumentException("subject cannot be null");
this.subject = subject;
setDefaultCloseOperation(EXIT_ON_CLOSE);
panel = new JPanel();
getContentPane().add(panel);
panel.setLayout(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(25, 25, 25, 25));
}
/**
* Returns the subject this GUI sends data to
*
* @return the subject this GUI sends data to
*/
public SubjectInterface getSubject() {
return subject;
}
/**
* returns the panel this GUI displays widgets on
*
* @return the panel this GUI displays widgets on
*/
public JPanel getPanel() {
return panel;
}
}