-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPanelRobot.java
77 lines (69 loc) · 2.29 KB
/
PanelRobot.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package graphics;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.BorderFactory;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class PanelRobot extends JPanel {
private final JLabel Nb_Robot = new JLabel("Robot numero: ");
String Type_Robot[] = { "Aleatoire", "Tireur", "Piegeur", "Char" };
private final JComboBox combo = new JComboBox(Type_Robot);
int nbRobot;
private String robot[] = new String[nbRobot];
String robot_choisi[] = new String[5];
public PanelRobot(int i) {
nbRobot = i;
this.setBackground(Color.white);
Nb_Robot.setText(Nb_Robot.getText() + "" + i);
this.setPreferredSize(new Dimension(300, 50));
this.setLayout(new BorderLayout());
this.add(Nb_Robot, BorderLayout.WEST);
this.add(combo, BorderLayout.EAST);
combo.setPreferredSize(new Dimension(150, 40));
combo.setFont((new Font("serif", Font.BOLD, 15)));
Nb_Robot.setFont((new Font("serif", Font.BOLD, 15)));
combo.setBackground(Color.white);
this.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.black));
//combo.addActionListener(new ItemState());
}
/*
public String get_robot_choisi(int i){ // i correspond au numero du robot genre robot 1,2... et ça retourne un string du genre char aleatoire ....s
return robot_choisi[i];
}
class ItemState implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
//System.out.println("ActionListener : action sur " +
//combo.getSelectedItem());
switch(nbRobot){
case 1:
robot_choisi[1]= (String) combo.getSelectedItem();
System.out.println(robot_choisi[1]);
break;
case 2:
robot_choisi[2]= (String) combo.getSelectedItem();
System.out.println(robot_choisi[2]);
break;
case 3:
robot_choisi[3]= (String) combo.getSelectedItem();
System.out.println(robot_choisi[3]);
break;
case 4:
robot_choisi[4]= (String) combo.getSelectedItem();
System.out.println(robot_choisi[4]);
break;
case 5:
robot_choisi[5]= (String) combo.getSelectedItem();
System.out.println(robot_choisi[5]);
break;
}
}
}*/
}