Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
5277 connectés 

 


Dernière réponse
Sujet : [Swing] Lien entre un vector et une liste.
exo_ Euh tu fais quoi exactement ?
 
Vector v = new Vector(...);
JList j = new JList(v);
 
A mon humble avis, c'est précisément l'initialisation qui pose problème car "The contents of a JList can be dynamic, in other words, the list elements can change value and the size of the list can change after the JList has been created. The JList observes changes in its model with a swing.event.ListDataListener implementation. A correct implementation of ListModel notifies it's listeners each time a change occurs. The changes are characterized by a swing.event.ListDataEvent, which identifies the range of list indices that have been modified, added, or removed. Simple dynamic-content JList applications can use the DefaultListModel class to store list elements. This class implements the ListModel interface and provides the java.util.Vector API as well. Applications that need to provide custom ListModel implementations can subclass AbstractListModel, which provides basic ListDataListener support."

Votre réponse
Nom d'utilisateur    Pour poster, vous devez être inscrit sur ce forum .... si ce n'est pas le cas, cliquez ici !
Le ton de votre message                        
                       
Votre réponse


[b][i][u][strike][spoiler][fixed][cpp][url][email][img][*]   
 
   [quote]
 

Options

 
Vous avez perdu votre mot de passe ?


Vue Rapide de la discussion
exo_ Euh tu fais quoi exactement ?
 
Vector v = new Vector(...);
JList j = new JList(v);
 
A mon humble avis, c'est précisément l'initialisation qui pose problème car "The contents of a JList can be dynamic, in other words, the list elements can change value and the size of the list can change after the JList has been created. The JList observes changes in its model with a swing.event.ListDataListener implementation. A correct implementation of ListModel notifies it's listeners each time a change occurs. The changes are characterized by a swing.event.ListDataEvent, which identifies the range of list indices that have been modified, added, or removed. Simple dynamic-content JList applications can use the DefaultListModel class to store list elements. This class implements the ListModel interface and provides the java.util.Vector API as well. Applications that need to provide custom ListModel implementations can subclass AbstractListModel, which provides basic ListDataListener support."
kadreg Bonjour,
 
J'ai un Vector contenant des Strings destinées à etre affiché à la fois par une JList et une JComboBox. A l'initialization, ca rulez.
 
Maintenant si le programme rajoute un element dans le vector (monVector.add ("toto" )), ma combo se met a jour, mais ma JList plante et ne s'affiche plus (pas de levée d'exception).
 
 
Quel peut etre le probleme ?

Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)