package views; import controls.PhaseController; import resources.Algo; import javax.swing.*; import java.awt.*; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; public class MainFrame extends JFrame { public MainFrame() { super("Algolike"); var algo = new Algo(); var mainPanel = new MainPanel(algo); var phaseController = new PhaseController(algo); mainPanel.bindPhaseController(phaseController); phaseController.bindGameView(mainPanel); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainPanel.setVisible(true); this.add(mainPanel, BorderLayout.CENTER); this.pack(); this.addWindowListener(new WindowListener() { @Override public void windowOpened(WindowEvent e) { mainPanel.repaintBoard(mainPanel.abstractGameState); mainPanel.onStartPlayerTurn(mainPanel.abstractGameState); } @Override public void windowClosing(WindowEvent e) { } @Override public void windowClosed(WindowEvent e) { } @Override public void windowIconified(WindowEvent e) { } @Override public void windowDeiconified(WindowEvent e) { } @Override public void windowActivated(WindowEvent e) { } @Override public void windowDeactivated(WindowEvent e) { } }); } }