JAVA : Préselection JComboBox

yserman Messages postés 39 Date d'inscription   Statut Membre Dernière intervention   -  
choubaka Messages postés 39442 Date d'inscription   Statut Modérateur Dernière intervention   -
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
A voir également:

3 réponses

yserman Messages postés 39 Date d'inscription   Statut Membre Dernière intervention   2
 
uuuuu ?????
0
yserman Messages postés 39 Date d'inscription   Statut Membre Dernière intervention   2
 
Heeeeelp
0
choubaka Messages postés 39442 Date d'inscription   Statut Modérateur Dernière intervention   2 105
 
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
0
maily Messages postés 7556 Date d'inscription   Statut Contributeur Dernière intervention   453
 
Oh! de la javadoc! En plus, celle de JComboBox!
0
choubaka Messages postés 39442 Date d'inscription   Statut Modérateur Dernière intervention   2 105
 
la javabible, 'achement utile pour programmer ma petite mamoiselle...
0