JAVA : Préselection JComboBox
yserman
Messages postés
39
Statut
Membre
-
choubaka Messages postés 39984 Statut Modérateur -
choubaka Messages postés 39984 Statut Modérateur -
Salut à tous ,
J'ai un problème avec ma une de mes JComboBox , en fait elle contient une colonne d'une de mes tables (via un vecteur) et je voudrais qu'elle soit sur une valeur précise , mais ca foire...
mon code :
choixcategorie = new JComboBox ();
choixcategorie.setSelectedItem (modcategorie);
choixcategorie.setMaximumRowCount(3);
choixcategorie.setBounds (120, 105,200,30);
choixcategorie.setBackground(Color.WHITE);
cont.add (choixcategorie);
quand à la place de modcategorie je tape une valeur constante entre "" ca marche mais quand c'est une variable ben ca marche pas !!
si on peut me dire ce que c'est mon erreur....
D'avance merci
J'ai un problème avec ma une de mes JComboBox , en fait elle contient une colonne d'une de mes tables (via un vecteur) et je voudrais qu'elle soit sur une valeur précise , mais ca foire...
mon code :
choixcategorie = new JComboBox ();
choixcategorie.setSelectedItem (modcategorie);
choixcategorie.setMaximumRowCount(3);
choixcategorie.setBounds (120, 105,200,30);
choixcategorie.setBackground(Color.WHITE);
cont.add (choixcategorie);
quand à la place de modcategorie je tape une valeur constante entre "" ca marche mais quand c'est une variable ben ca marche pas !!
si on peut me dire ce que c'est mon erreur....
D'avance merci
A voir également:
- JAVA : Préselection JComboBox
- Jeux java itel - Télécharger - Jeux vidéo
- Waptrick java football - Télécharger - Jeux vidéo
- Waptrick java voiture - Télécharger - Jeux vidéo
- Eclipse java - Télécharger - Langages
- Java apk - Télécharger - Langages
3 réponses
salut
essaye avec ça
public void setSelectedIndex(int anIndex)
Selects the item at index anIndex.
Parameters:
anIndex - an integer specifying the list item to select, where 0 specifies the first item in the list
Throws:
IllegalArgumentException - if anIndex < -1 or anIndex is greater than or equal to size
essaye avec ça
public void setSelectedIndex(int anIndex)
Selects the item at index anIndex.
Parameters:
anIndex - an integer specifying the list item to select, where 0 specifies the first item in the list
Throws:
IllegalArgumentException - if anIndex < -1 or anIndex is greater than or equal to size