JAVA : Préselection JComboBox

yserman Messages postés 39 Date d'inscription   Statut Membre -  
choubaka Messages postés 5534 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

3 réponses

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