周浩 8月17日 完善teamcreate的ui类
This commit is contained in:
parent
d2229cb09d
commit
ff97ccfd1d
|
@ -32,8 +32,8 @@ public class TeamCreator extends JDialog implements WizardListener {
|
|||
private RobotSelectionPanel robotSelectionPanel;
|
||||
private TeamCreatorOptionsPanel teamCreatorOptionsPanel;
|
||||
|
||||
private final int minRobots = 2;
|
||||
private final int maxRobots = 10;
|
||||
private final int minRobots = 2;//每个编队至少两人
|
||||
private final int maxRobots = 10;//每个编队最多10人
|
||||
|
||||
private final EventHandler eventHandler = new EventHandler();
|
||||
|
||||
|
@ -76,7 +76,9 @@ public class TeamCreator extends JDialog implements WizardListener {
|
|||
return teamCreatorContentPane;
|
||||
}
|
||||
|
||||
//选择机器人组成编队
|
||||
protected RobotSelectionPanel getRobotSelectionPanel() {
|
||||
//如果当前选择为空
|
||||
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,
|
||||
|
@ -94,6 +96,7 @@ public class TeamCreator extends JDialog implements WizardListener {
|
|||
return wizardPanel;
|
||||
}
|
||||
|
||||
//窗口初始化
|
||||
public void initialize() {
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle("Create a team");
|
||||
|
@ -106,11 +109,12 @@ public class TeamCreator extends JDialog implements WizardListener {
|
|||
}
|
||||
return wizardController;
|
||||
}
|
||||
|
||||
//添加取消键动作
|
||||
public void cancelButtonActionPerformed() {
|
||||
dispose();
|
||||
}
|
||||
|
||||
//添加完成键动作
|
||||
public void finishButtonActionPerformed() {
|
||||
try {
|
||||
int rc = createTeam();
|
||||
|
@ -128,12 +132,14 @@ public class TeamCreator extends JDialog implements WizardListener {
|
|||
}
|
||||
}
|
||||
|
||||
//将创建的编队写入数据库
|
||||
public int createTeam() throws IOException {
|
||||
File file = new File(repositoryManager.getRobotsDirectory(),
|
||||
teamCreatorOptionsPanel.getTeamPackage().replace('.', File.separatorChar)
|
||||
+ teamCreatorOptionsPanel.getTeamNameField().getText() + ".team");
|
||||
|
||||
if (file.exists()) {
|
||||
//如果当前编队已经存在
|
||||
int ok = JOptionPane.showConfirmDialog(this, file + " already exists. Are you sure you want to replace it?",
|
||||
"Warning", JOptionPane.YES_NO_CANCEL_OPTION);
|
||||
|
||||
|
|
Loading…
Reference in New Issue