-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObserver.java
More file actions
42 lines (38 loc) · 1.67 KB
/
Copy pathObserver.java
File metadata and controls
42 lines (38 loc) · 1.67 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
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
public class Observer extends GuiClass implements ObserverInterface {
private ArrayList<ArtSupply> artSupplies;
public Observer(SubjectInterface subject) {
super(subject);
subject.register(this);
setTitle("Results Window");
setPreferredSize(new Dimension(400, 600));
setMinimumSize(new Dimension(300, 150));
getPanel().setLayout(new BoxLayout(getPanel(), BoxLayout.PAGE_AXIS));
getPanel().setBorder(BorderFactory.createEmptyBorder(25, 25, 25, 25));
}
public void update() {
getPanel().removeAll();
getPanel().repaint();
JLabel title = new JLabel("Results");
title.setFont(new Font("Serif", Font.BOLD, 20));
title.setAlignmentX(Component.CENTER_ALIGNMENT);
getPanel().add(title);
getPanel().add(Box.createRigidArea(new Dimension(0, 10)));
artSupplies = getSubject().getData();
for (ArtSupply artSupply : artSupplies) {
JLabel artSupplyDisplay = new JLabel(artSupply.toString());
getPanel().add(artSupplyDisplay);
artSupplyDisplay.setBackground(Color.RED);
artSupplyDisplay.setOpaque(true);
artSupplyDisplay.setAlignmentX(Component.CENTER_ALIGNMENT);
}
pack();
validate();
setVisible(true);
//TODO: try returning an HTML String from the ArtSupply class and displaying them all in a Widget, then
//Just remove that widget so you don't have to redo all the setup
//Put the setup in the constructor
}
}