Initializes the GUI
()
| 57 | * Initializes the GUI |
| 58 | */ |
| 59 | private void initGUI() { |
| 60 | this.field = new PlayField(world, this); |
| 61 | |
| 62 | this.field.addMouseListener(new PlayfieldMouseHandler()); |
| 63 | this.field.addMouseWheelListener(new PlayfieldMouseHandler()); |
| 64 | |
| 65 | this.guiControls = new GUIControls(this,this.field); |
| 66 | this.eventLogPanel = new EventLogPanel(this); |
| 67 | this.infoPanel = new InfoPanel(this); |
| 68 | this.main = new MainWindow(this.scen.getName(), world, field, |
| 69 | guiControls, infoPanel, eventLogPanel, this); |
| 70 | |
| 71 | scen.addMessageListener(eventLogPanel); |
| 72 | scen.addConnectionListener(eventLogPanel); |
| 73 | |
| 74 | if (scen.getMap() != null ) { |
| 75 | field.setMap(scen.getMap()); |
| 76 | } |
| 77 | |
| 78 | // if user closes the main window, call closeSim() |
| 79 | this.main.addWindowListener(new WindowAdapter() { |
| 80 | private boolean closeAgain = false; |
| 81 | public void windowClosing(WindowEvent e) { |
| 82 | closeSim(); |
| 83 | if (closeAgain) { |
| 84 | // if method is called again, force closing |
| 85 | System.err.println("Forced close. "+ |
| 86 | "Some reports may have not been finalized."); |
| 87 | System.exit(-1); |
| 88 | } |
| 89 | closeAgain = true; |
| 90 | } |
| 91 | }); |
| 92 | |
| 93 | this.main.setVisible(true); |
| 94 | } |
| 95 | |
| 96 | @Override |
| 97 | protected void runSim() { |
no test coverage detected