/** Handle OK/Cancel selections */ @Override public void close(String actionCommand) { super.close(actionCommand); if (isOKorAccept(actionCommand)) { World world = clientFrame.getWorld(); // this isn't really the way to do it GamePanel gp = (GamePanel) tabPane.getComponentAt(0); GameMetadata gmd = new GameMetadata(); gp.write(gmd); world.setGameMetadata(gmd); // assume panels 1-n are all player panels for (int i = 1; i < tabPane.getTabCount(); i++) { PlayerPanel pp = (PlayerPanel) tabPane.getComponentAt(i); PlayerMetadata pmd = new PlayerMetadata(); pp.write(pmd); world.setPlayerMetadata(pp.getPower(), pmd); } // set data-changed flag clientFrame.fireStateModified(); } if (propertyListener != null) { clientFrame.removePropertyChangeListener(propertyListener); } } // close()
/** Sets the tab icons for each power. */ private void setTabIcons() { if (mmd != null) { final World world = clientFrame.getWorld(); final int tabCount = tabPane.getTabCount(); for (int i = 1; i < tabCount; i++) // no icon for 'game' info { Power power = world.getMap().getPower(tabPane.getTitleAt(i)); assert (power != null); String colorName = mmd.getPowerColor(power); Color color = SVGColorParser.parseColor(colorName); tabPane.setIconAt(i, new ColorRectIcon(12, 12, color)); } } } // setTabIcons()
/** Make the tab panel */ private void makeTabPanel() { // create tabbed pane tabPane = new JTabbedPane(); // first tab is Game info World world = clientFrame.getWorld(); tabPane.add(Utils.getLocalString(TAB_GAME_PANEL), makeGamePanel(world.getGameMetadata())); // all other tabs are by Power name Power[] powers = world.getMap().getPowers(); for (int i = 0; i < powers.length; i++) { tabPane.add( powers[i].getName(), makePlayerPanel(powers[i], world.getPlayerMetadata(powers[i]))); } } // makeTabPanel()