I currently have a large number of lines in my code:
Below the player insertion part, these players will have the names searched from the bank and sent by cmb box.
private void Verificar() {
String jogadores = JOptionPane.showInputDialog(null, "Selecione a quantidade de jogadores.");
setLayout(new FlowLayout()); //configura o layout de frame
if (null != jogadores) {
if ("1".equals(jogadores)
|| "2".equals(jogadores) || "3".equals(jogadores)
|| "4".equals(jogadores) || "5".equals(jogadores)
|| "6".equals(jogadores) || "7".equals(jogadores)
|| "8".equals(jogadores) || "9".equals(jogadores)
|| "10".equals(jogadores) || "11".equals(jogadores)
|| "12".equals(jogadores) || "13".equals(jogadores)
|| "14".equals(jogadores) || "15".equals(jogadores)
|| "16".equals(jogadores) || "17".equals(jogadores)
|| "18".equals(jogadores) || "19".equals(jogadores)
|| "20".equals(jogadores) || "21".equals(jogadores)
|| "22".equals(jogadores) || "23".equals(jogadores)
|| "24".equals(jogadores) || "25".equals(jogadores)
|| "26".equals(jogadores) || "27".equals(jogadores)
|| "28".equals(jogadores) || "29".equals(jogadores)
|| "30".equals(jogadores) || "31".equals(jogadores)
|| "32".equals(jogadores) || "33".equals(jogadores)
|| "34".equals(jogadores) || "35".equals(jogadores)
|| "36".equals(jogadores) || "37".equals(jogadores)
|| "38".equals(jogadores) || "39".equals(jogadores)
|| "40".equals(jogadores)) {
switch (jogadores) {
case "1":
setSize(460, 65);
setTitle("Selecione os jogadores");
J1();
break;
} // fim switch
} // fim if gigante
} // fim if not null
} // fim método verificar
private void J1() {
JLabel jog1 = new JLabel("Nome do jogador: ");
add(jog1);
jog1.setVerticalTextPosition(SwingConstants.BOTTOM);
JComboBox cbj1 = new JComboBox();
add(cbj1);
cbj1.setModel(new javax.swing.DefaultComboBoxModel(new String[] {" "}));
JLabel jog2 = new JLabel("Número da cartela: ");
add(jog2);
jog2.setVerticalTextPosition(SwingConstants.BOTTOM);
JComboBox cbj2 = new JComboBox();
add(cbj2);
cbj2.setModel(new javax.swing.DefaultComboBoxModel(new String[] {" "}));
} // fim J1
In bold at the beginning of the code I put the 40 "case" I am using, for each CASE there is a Jx being x the number of players that the user informs.
No private void J1 () I used as an example because the code would be HUGE It's making it hard for me to keep the code.
I would like to know if there is a way to concatenate the prefix J with the number of players that the user tells me to play this on the screen so that the user fill in the combo box the players name of the match, remembering that there are several cases currently, I thought of creating just one function that would make this control, without messing up my interface.