Bonjour à tous,
donc voilà j'ai un petit problème concernant l'affichage d'élément d'une arraylist
j'ai donc créer une nouvelle liste d'objets commande (comportant le nom du client et ses coordonnées géographiques)
private static ArrayList<Command> arrList = new ArrayList<Command>();
Je choisi un client parmis ceux présent dans la ComboBox
1 2 3 4 5 6 7
| ComboBoxModel jComboBox1Model = new DefaultComboBoxModel( new String[] { });
jComboBox2 = new JComboBox();
jComboBox2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
selectClient1();
}
}); |
1 2 3 4 5 6 7 8
| private void selectClient1() {
int index = jComboBox2.getSelectedIndex();
if (index >= 0) {
client1 = clientDataBase.get(index);
jLabel22.setText(client1.getName());
} else
client1 = null;
} |
Je valide ensuite la commande et je l'ajoute donc à ma liste
1 2 3 4 5
| jBValider1 = new JButton();
jBValider1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Command commande=new Command(client1.getName(),client1.getxCoordinate(),client1.getyCoordinate());
arrList.add(commande); |
Sachant que j'ai plusieurs client, je peux donc avoir plusieurs commandes, c'est donc ici que ça coince, lorsque je souhaite afficher les différents noms des clients qui ont passé une commande, ça m'affiche seulement le nom du client correspondant à la derniere commande passée
1 2 3 4 5 6 7 8
| jBAfficher = new JButton()
jBAfficher.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
for (Command commande : arrList) {
jLabel24.setText(commande.getNomClient());
}
}
}); |
j'espère avoir été assez clair 
merci d'avance pour votre aide et bonne soirée
Partager