private void initComponents() { JPanel windowPanel = new JPanel(); windowPanel.setLayout(new BoxLayout(windowPanel, BoxLayout.PAGE_AXIS)); JTabbedPane localSettingsTabbedPane = new javax.swing.JTabbedPane(); localSettingsTabbedPane.setName("localSettingsTab"); // $NON-NLS-1$ JPanel tabs = new JPanel(); tabs.setLayout(new BoxLayout(tabs, BoxLayout.LINE_AXIS)); windowPanel.add(Box.createRigidArea(new Dimension(0, 5))); windowPanel.add(tabs); tabs.add(Box.createRigidArea(new Dimension(5, 0))); tabs.add(localSettingsTabbedPane); tabs.add(Box.createRigidArea(new Dimension(5, 0))); localSettingsTab = new LocalSettingsTab(this); localSettingsTab.setLayout(new BoxLayout(localSettingsTab, BoxLayout.PAGE_AXIS)); localSettingsTabbedPane.addTab( Language.getString("local_game"), localSettingsTab); // $NON-NLS-1$ createButtonArea(windowPanel); add(windowPanel); pack(); }
private void okButtonPressed() { if (localSettingsTab.areSettingsValid() == false) { JOptionPane.showMessageDialog(this, Language.getString("fill_names")); // $NON-NLS-1$ return; } try { Settings.addPlayerName(localSettingsTab.getPlayerName(PlayerColor.WHITE), PlayerColor.WHITE); Settings.addPlayerName(localSettingsTab.getPlayerName(PlayerColor.BLACK), PlayerColor.BLACK); Settings.addPlayerName(localSettingsTab.getPlayerName(PlayerColor.RED), PlayerColor.RED); GameTab newGUI = JChessView.getInstance() .addNewTab( MessageFormat.format( "{0} vs {1} vs {2}", localSettingsTab.getPlayerName(PlayerColor.WHITE), localSettingsTab.getPlayerName(PlayerColor.RED), localSettingsTab.getPlayerName(PlayerColor.BLACK))); if (localSettingsTab.isTimeLimitSet()) // if timeGame is checked { Settings.setTimeLimitSet(true); try { Settings.setTimeForGame((int) localSettingsTab.getSelectedTimeLimit() * 60); } catch (Exception e) { Logging.log(e); /* * Should never happen, because user can only chose between correct * values. IGNORE Exception */ } } newGUI.newGame(); /* * Hide dialog, if everything worked as expected, leave dialog open * otherwise. */ setVisible(false); newGUI.getChessboardUI().repaint(); } catch (Exception exc) { JOptionPane.showMessageDialog(this, "Error occurred:\n" + exc.getMessage()); // $NON-NLS-1$ Logging.log(exc); } }