1 package com.nilhcem.fakesmtp.gui.tab;
2
3 import com.nilhcem.fakesmtp.gui.info.ClearAllButton;
4 import com.nilhcem.fakesmtp.model.EmailModel;
5 import com.nilhcem.fakesmtp.server.MailSaver;
6
7 import javax.swing.JScrollPane;
8 import javax.swing.JTextArea;
9 import java.util.Observable;
10 import java.util.Observer;
11
12
13
14
15
16
17
18 public final class LastMailPane implements Observer {
19
20 private final JScrollPane lastMailPane = new JScrollPane();
21 private final JTextArea lastMailArea = new JTextArea();
22
23
24
25
26 public LastMailPane() {
27 lastMailArea.setEditable(false);
28 lastMailPane.getViewport().add(lastMailArea, null);
29 }
30
31
32
33
34
35
36 public JScrollPane get() {
37 return lastMailPane;
38 }
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 @Override
54 public synchronized void update(Observable o, Object data) {
55 if (o instanceof MailSaver) {
56 EmailModel model = (EmailModel) data;
57 lastMailArea.setText(model.getEmailStr());
58 } else if (o instanceof ClearAllButton) {
59 lastMailArea.setText("");
60 }
61 }
62 }