From 6471effdaed19124cf27be7e6c5dbe7d00dbb00b Mon Sep 17 00:00:00 2001 From: zhoudaxia <1018795633@qq.cin> Date: Thu, 18 Aug 2016 22:31:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=A8=E6=B5=A9=20=208=E6=9C=8818=E6=97=A5?= =?UTF-8?q?=20=E5=AE=8C=E5=96=84ui=E4=B8=ADTeamCreator=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../net/sf/robocode/ui/dialog/TeamCreator.java | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/代码/robocode/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/TeamCreator.java b/代码/robocode/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/TeamCreator.java index 5f06615..865688b 100644 --- a/代码/robocode/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/TeamCreator.java +++ b/代码/robocode/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/TeamCreator.java @@ -37,9 +37,12 @@ public class TeamCreator extends JDialog implements WizardListener { private final EventHandler eventHandler = new EventHandler(); + //EventHandlerʵActionListenerӿڣʵֶļ class EventHandler implements ActionListener { public void actionPerformed(ActionEvent e) { + //eΪIJʱeΪActionEvent if (e.getActionCommand().equals("Refresh")) { + //ִи² getRobotSelectionPanel().refreshRobotList(true); } } @@ -60,9 +63,12 @@ public class TeamCreator extends JDialog implements WizardListener { return teamCreatorOptionsPanel; } + //ȡǶе private JPanel getTeamCreatorContentPane() { if (teamCreatorContentPane == null) { + //ǶΪ teamCreatorContentPane = new JPanel(); + //½Ƕ teamCreatorContentPane.setLayout(new BorderLayout()); teamCreatorContentPane.add(getWizardController(), BorderLayout.SOUTH); teamCreatorContentPane.add(getWizardPanel(), BorderLayout.CENTER); @@ -77,9 +83,11 @@ public class TeamCreator extends JDialog implements WizardListener { } //ѡɱ - protected RobotSelectionPanel getRobotSelectionPanel() { + protected RobotSelectionPanel getRobotSelectionPanel() + { //ǰѡΪ - if (robotSelectionPanel == null) { + if (robotSelectionPanel == null) + { robotSelectionPanel = net.sf.robocode.core.Container.createComponent(RobotSelectionPanel.class); robotSelectionPanel.setup(minRobots, maxRobots, false, "Select the robots for this team.", false, true, true, false, false, false, null); @@ -87,8 +95,10 @@ public class TeamCreator extends JDialog implements WizardListener { return robotSelectionPanel; } - private WizardCardPanel getWizardPanel() { - if (wizardPanel == null) { + private WizardCardPanel getWizardPanel() + { + if (wizardPanel == null) + { wizardPanel = new WizardCardPanel(this); wizardPanel.add(getRobotSelectionPanel(), "Select robots"); wizardPanel.add(getTeamCreatorOptionsPanel(), "Select options"); @@ -97,14 +107,16 @@ public class TeamCreator extends JDialog implements WizardListener { } //ڳʼ - public void initialize() { + public void initialize() + { setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setTitle("Create a team"); setContentPane(getTeamCreatorContentPane()); } private WizardController getWizardController() { - if (wizardController == null) { + if (wizardController == null) + { wizardController = getWizardPanel().getWizardController(); } return wizardController; @@ -157,10 +169,13 @@ public class TeamCreator extends JDialog implements WizardListener { String webPageFieldString = teamCreatorOptionsPanel.getWebpageField().getText(); if (webPageFieldString != null && webPageFieldString.length() > 0) { - try { + try + { webPageUrl = new URL(webPageFieldString); - } catch (MalformedURLException e) { - try { + } catch (MalformedURLException e) + { + try + { webPageUrl = new URL("http://" + webPageFieldString); teamCreatorOptionsPanel.getWebpageField().setText(webPageUrl.toString()); } catch (MalformedURLException ignored) {}