aspose file tools*
The moose likes Java in General and the fly likes Updating JList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Updating JList" Watch "Updating JList" New topic
Author

Updating JList

Marvin Legend
Greenhorn

Joined: Oct 18, 2013
Posts: 26
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

Joined: Oct 31, 2011
Posts: 484

You should use ListModel for the JList, so the data gets updated automatically.


PM Me If You Want to get Urgent Help on Java Programming
Marvin Legend
Greenhorn

Joined: Oct 18, 2013
Posts: 26
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

Joined: Jul 26, 2007
Posts: 9990
    
    7

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


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Marvin Legend
Greenhorn

Joined: Oct 18, 2013
Posts: 26
Nam Ha Minh wrote:You should use ListModel for the JList, so the data gets updated automatically.


Thanks bro !
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 484

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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Updating JList
 
Similar Threads
GUI and events
request parameters persisting across pages
enter key events in a page containing 2 or more than 2 buttons
Won't repaint!
JList set element visible