Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Updating JList

 
Marvin Legend
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys
greetings

I'm having problems to update a JList, the numerical values ​​that are in the JList are variables of other classes, and I would like that when I alter the value of these variables in other classes, and pressed the button "Refresh" in class FrameTeste the data in the JList would be updated according to the changes I made in the other classes, I created an example of two different classes of variables with different values ​​and a class that is the frame, it has a JList and button "Refresh",

Exemple :

![enter image description here][1]


![enter image description here][2]


And the Frame Class :


[1]: http://i.stack.imgur.com/2kTum.jpg
[2]: http://i.stack.imgur.com/rVfV9.jpg
[3]: http://i.stack.imgur.com/2A2pd.jpg

when I change the value of variables that belong to OtherClass1 and OtherClass2 and press the refresh button in the Frame class, I would like the values ​​to be updated JList, I've tried everything, but without success. Thank you guys.
 
Nam Ha Minh
Ranch Hand
Posts: 502
Eclipse IDE Firefox Browser Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should use ListModel for the JList, so the data gets updated automatically.
 
Marvin Legend
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nam Ha Minh wrote:You should use ListModel for the JList, so the data gets updated automatically.


How my brother ? Can give a exemple ? Can explain to me ?
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marvin Legend wrote:
How my brother ? Can give a exemple ? Can explain to me ?

Did you check out the API docs? It has an example of how the data is wrapped inside a model.
Almost all swing components have a How to use xxx linked on the API. Check out the list version here http://docs.oracle.com/javase/tutorial/uiswing/components/list.html
 
Marvin Legend
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nam Ha Minh wrote:You should use ListModel for the JList, so the data gets updated automatically.


Thanks bro !
 
Nam Ha Minh
Ranch Hand
Posts: 502
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marvin Legend wrote:
Nam Ha Minh wrote:You should use ListModel for the JList, so the data gets updated automatically.


Thanks bro !


You're welcome. Did you get your problem solved?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic