/** Update the status of the GUI based on any changes in the game object. */ private void updateStatus() { if (game.donePlacingShips()) { // Kill the ship highlight and disable the vertical/horizontal buttons. humanGrid.setHoverShape(null); hButton.setEnabled(false); vButton.setEnabled(false); } else { int len = game.placingLength(); boolean horiz = game.placingHorizontal(); humanGrid.setHoverShape(new Dimension(horiz ? len : 1, horiz ? 1 : len)); } message.setText(game.getStatus()); repaint(); }
public void actionPerformed(ActionEvent e) { if (e.getSource().equals(save)) new GridSaver(grid, fileName()); if (e.getSource().equals(load)) { GridLoader gl = new GridLoader(grid, fileName()); try { grid.setMap(gl.read()); } catch (IOException ioex) { System.out.println("File load Failed ioex"); } } parent.getParent().refresh(); }