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> { @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; } }