public void handleLoad() { JFileChooser fc = new JFileChooser(System.getProperty("user.dir") + System.getProperty("file.separator") + "saves"); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setDialogTitle(_("Load game")); fc.setDialogType(JFileChooser.OPEN_DIALOG); fc.setFileFilter(new SavegameFileFilter()); fc.setLocale(getLocale()); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); if (file != null) { if (!closeGame()) return; try { localServer = new Server(new Snapshot(file)); localServer.start(config.getPort()); connect(InetAddress.getLocalHost(), config.getPort()); } catch (SnapshotVersionException ex1) { //do not create error.log JOptionPane.showMessageDialog(this, ex1.getLocalizedMessage(), _("Error"), JOptionPane.ERROR_MESSAGE); } catch (Exception ex) { logger.error(ex.getMessage(), ex); JOptionPane.showMessageDialog(this, ex.getLocalizedMessage(), _("Error"), JOptionPane.ERROR_MESSAGE); } } } }
public void createGame() { if (!closeGame()) return; try { localServer = new Server(config); localServer.start(config.getPort()); connect(InetAddress.getLocalHost(), config.getPort()); } catch (IOException e) { logger.error(e.getMessage(), e); JOptionPane.showMessageDialog(this, e.getMessage(), _("Error"), JOptionPane.ERROR_MESSAGE); closeGame(true); } }