[Débutant] [JComboBox] Gestion de doublons
Salut à tous,
une question très simple qui pourtant me pose problème.
Je manipule une JComboBox et je en désire pas ajouter de doublons et cela me pose porblème.
En effet ma JComboBox n'est pas éditable, l'information vient d'une JTable, et par conséquent je ne peux pas utiliser la méthode suivante :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
//savoir si le mot est déjà dans la comboBox
boolean notIn = true;
if(tmpAjouter.jComboBoxMots.getItemCount() != 0) {
String tmpString = (String)tmpAjouter.jComboBoxMots.getSelectedItem();
tmpAjouter.jComboBoxMots.setSelectedItem(Tbuff[i]);
if(tmpAjouter.jComboBoxMots.getSelectedIndex() != -1)
notIn = false;
tmpAjouter.jComboBoxMots.setSelectedItem(tmpString);
} |
Je vous remercie de votre aide.
Olivier.