Forums Register Login

Updating JList

+Pie Number of slices to send: Send
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.
1
+Pie Number of slices to send: Send
You should use ListModel for the JList, so the data gets updated automatically.
+Pie Number of slices to send: Send
 

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 ?

 
+Pie Number of slices to send: Send
 

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
+Pie Number of slices to send: Send
 

Nam Ha Minh wrote:You should use ListModel for the JList, so the data gets updated automatically.



Thanks bro !
+Pie Number of slices to send: Send
 

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?
What are you doing? You are supposed to be reading this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 936 times.
Similar Threads
Won't repaint!
request parameters persisting across pages
JList set element visible
enter key events in a page containing 2 or more than 2 buttons
GUI and events
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:11:12.