Use spinner instead of combobox for AI skill. Fix #1111 and #118

This commit is contained in:
Plopman 2017-02-14 21:06:07 +01:00
parent e54b81785d
commit 10284642bc
4 changed files with 59 additions and 70 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
@ -26,20 +26,21 @@
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="txtPlayerName" pref="321" max="32767" attributes="2"/>
<Component id="txtPlayerDeck" alignment="0" pref="321" max="32767" attributes="2"/>
<Component id="txtPlayerName" pref="310" max="32767" attributes="2"/>
<Component id="txtPlayerDeck" alignment="0" pref="310" max="32767" attributes="2"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Group type="102" attributes="0">
<Component id="btnPlayerDeck" min="-2" pref="24" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnGenerate" min="-2" pref="87" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="lblLevel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbLevel" min="-2" pref="54" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="spnLevel" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="64" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
@ -52,7 +53,7 @@
<Component id="txtPlayerName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblPlayerName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblLevel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbLevel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnLevel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="3" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
@ -101,21 +102,10 @@
<Property name="text" type="java.lang.String" value="Skill:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="cbLevel">
<Component class="javax.swing.JSpinner" name="spnLevel">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="10">
<StringItem index="0" value="1"/>
<StringItem index="1" value="2"/>
<StringItem index="2" value="3"/>
<StringItem index="3" value="4"/>
<StringItem index="4" value="5"/>
<StringItem index="5" value="6"/>
<StringItem index="6" value="7"/>
<StringItem index="7" value="8"/>
<StringItem index="8" value="9"/>
<StringItem index="9" value="10"/>
</StringArray>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="6" maximum="10" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>

View file

@ -66,9 +66,6 @@ public class NewPlayerPanel extends javax.swing.JPanel {
if (Config.defaultComputerName != null) {
this.txtPlayerName.setText(Config.defaultComputerName);
}
if (cbLevel.getModel().getSize() > 0) {
cbLevel.setSelectedIndex(cbLevel.getModel().getSize()/2);
}
}
public void setPlayerName(String playerName) {
@ -115,11 +112,11 @@ public class NewPlayerPanel extends javax.swing.JPanel {
public int getLevel() {
return Integer.valueOf((String)this.cbLevel.getSelectedItem());
return (Integer)spnLevel.getValue();
}
public void showLevel(boolean show) {
this.cbLevel.setVisible(show);
this.spnLevel.setVisible(show);
this.lblLevel.setVisible(show);
}
@ -146,21 +143,29 @@ public class NewPlayerPanel extends javax.swing.JPanel {
btnPlayerDeck = new javax.swing.JButton();
btnGenerate = new javax.swing.JButton();
lblLevel = new javax.swing.JLabel();
cbLevel = new javax.swing.JComboBox();
spnLevel = new javax.swing.JSpinner();
lblPlayerName.setText("Name:");
lblPlayerDeck.setText("Deck:");
btnPlayerDeck.setText("...");
btnPlayerDeck.addActionListener(evt -> btnPlayerDeckActionPerformed(evt));
btnPlayerDeck.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnPlayerDeckActionPerformed(evt);
}
});
btnGenerate.setText("Generate");
btnGenerate.addActionListener(evt -> btnGenerateActionPerformed(evt));
btnGenerate.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnGenerateActionPerformed(evt);
}
});
lblLevel.setText("Skill:");
cbLevel.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));
spnLevel.setModel(new javax.swing.SpinnerNumberModel(6, 1, 10, 1));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
@ -174,18 +179,19 @@ public class NewPlayerPanel extends javax.swing.JPanel {
.addComponent(lblPlayerName))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtPlayerName, javax.swing.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE)
.addComponent(txtPlayerDeck, javax.swing.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE))
.addComponent(txtPlayerName, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)
.addComponent(txtPlayerDeck, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(btnPlayerDeck, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnGenerate, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(lblLevel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbLevel, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(spnLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(64, 64, 64))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -194,7 +200,7 @@ public class NewPlayerPanel extends javax.swing.JPanel {
.addComponent(txtPlayerName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblPlayerName)
.addComponent(lblLevel)
.addComponent(cbLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(spnLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(3, 3, 3)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblPlayerDeck)
@ -216,10 +222,10 @@ public class NewPlayerPanel extends javax.swing.JPanel {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnGenerate;
private javax.swing.JButton btnPlayerDeck;
private javax.swing.JComboBox cbLevel;
private javax.swing.JLabel lblLevel;
private javax.swing.JLabel lblPlayerDeck;
private javax.swing.JLabel lblPlayerName;
private javax.swing.JSpinner spnLevel;
private javax.swing.JTextField txtPlayerDeck;
private javax.swing.JTextField txtPlayerName;
// End of variables declaration//GEN-END:variables

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
@ -78,11 +78,11 @@
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbLevel" min="-2" pref="54" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnLevel" min="-2" pref="51" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="67" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtPlayerName" pref="190" max="32767" attributes="0"/>
<Component id="txtPlayerName" pref="130" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -90,9 +90,9 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" alignment="0" groupAlignment="3" attributes="0">
<Component id="txtPlayerName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbLevel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnLevel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -110,23 +110,12 @@
<Property name="text" type="java.lang.String" value="Skill:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="cbLevel">
<Component class="javax.swing.JSpinner" name="spnLevel">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="10">
<StringItem index="0" value="1"/>
<StringItem index="1" value="2"/>
<StringItem index="2" value="3"/>
<StringItem index="3" value="4"/>
<StringItem index="4" value="5"/>
<StringItem index="5" value="6"/>
<StringItem index="6" value="7"/>
<StringItem index="7" value="8"/>
<StringItem index="8" value="9"/>
<StringItem index="9" value="10"/>
</StringArray>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="6" maximum="10" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
<Property name="selectedIndex" type="int" value="9"/>
<Property name="requestFocusEnabled" type="boolean" value="false"/>
</Properties>
</Component>
</SubComponents>

View file

@ -69,7 +69,7 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
tableId,
this.txtPlayerName.getText(),
(String)this.cbPlayerType.getSelectedItem(),
Integer.valueOf((String)this.cbLevel.getSelectedItem()),
(Integer)spnLevel.getValue(),
deckCardLists,
"");
}
@ -93,23 +93,27 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
txtPlayerName = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
cbLevel = new javax.swing.JComboBox();
spnLevel = new javax.swing.JSpinner();
jLabel1.setLabelFor(cbPlayerType);
jLabel1.setText("Type:");
cbPlayerType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbPlayerType.addActionListener(evt -> cbPlayerTypeActionPerformed(evt));
cbPlayerType.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbPlayerTypeActionPerformed(evt);
}
});
lblPlayerNum.setFont(new java.awt.Font("Tahoma", 1, 11));
lblPlayerNum.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
lblPlayerNum.setText("Player Num:");
jLabel2.setText("Name:");
jLabel3.setText("Skill:");
cbLevel.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));
cbLevel.setSelectedIndex(9);
spnLevel.setModel(new javax.swing.SpinnerNumberModel(6, 1, 10, 1));
spnLevel.setRequestFocusEnabled(false);
javax.swing.GroupLayout pnlPlayerNameLayout = new javax.swing.GroupLayout(pnlPlayerName);
pnlPlayerName.setLayout(pnlPlayerNameLayout);
@ -118,19 +122,19 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
.addGroup(pnlPlayerNameLayout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbLevel, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnLevel, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(67, 67, 67)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtPlayerName, javax.swing.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE))
.addComponent(txtPlayerName, javax.swing.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE))
);
pnlPlayerNameLayout.setVerticalGroup(
pnlPlayerNameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlPlayerNameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtPlayerName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(jLabel2))
.addComponent(jLabel2)
.addComponent(spnLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
@ -172,13 +176,13 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JComboBox cbLevel;
private javax.swing.JComboBox cbPlayerType;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel lblPlayerNum;
private javax.swing.JPanel pnlPlayerName;
private javax.swing.JSpinner spnLevel;
private javax.swing.JTextField txtPlayerName;
// End of variables declaration//GEN-END:variables