Newer
Older
Simon Könnecke
committed
package fucoin.supervisor;
import akka.japi.Creator;
import javax.swing.*;
import java.awt.*;
/**
* Create SuperVisor with a AWT Window.
* The window displays the information from the supervisor.
*/
public class SuperVisorCreator implements Creator<SuperVisorImpl> {
Simon Könnecke
committed
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
@Override
public SuperVisorImpl create() throws Exception {
//Show AWT window for runtime information
JFrame frame = new JFrame("Server");
frame.setLayout(new GridLayout(3, 2));
frame.add(new Label("All Amounts:"));
//Init Amount Table and SuperVisorImpl
AmountTableModel amountTableModel = new AmountTableModel();
SuperVisorImpl sv = new SuperVisorImpl(amountTableModel);
JTable amountListView = new JTable(amountTableModel);
Label averageAmountLbl = new Label("Average Amounts:");
frame.add(new JScrollPane(amountListView));
frame.add(new Label("Average Amounts:"));
frame.add(averageAmountLbl);
//Call update on supervisor
JButton updateBtn = new JButton("Update");
updateBtn.addActionListener(e -> sv.updateValues());
frame.add(updateBtn);
//Exit Button and shutdown supervisor
JButton exitBtn = new JButton("exit");
exitBtn.addActionListener(e -> {
sv.exit();
frame.setVisible(false);
});
frame.add(exitBtn);
frame.setSize(200, 400);
frame.setVisible(true);
return sv;
}
}