wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes JList Model Creation / Update Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JList Model Creation / Update" Watch "JList Model Creation / Update" New topic
Author

JList Model Creation / Update

Joe Pettit
Ranch Hand

Joined: Aug 16, 2012
Posts: 33

Hi everybody,
I'm having a bit of trouble getting a jlist component to work on one of my personal projects. I've initialized it and all, I have a model set which I am assuming is using the default list model, shown below:



Where getClassnames is a method that returns a string array. Basically where I need help is getting this jlist to update after new data is added to the getClassnames array. I've done some reading / searching and I've seen a couple different ways of creating a jlist model and it sounds like the default list model will not work - a lot of what I've seen rebuilds the model and sets the model after a change is made. I also read that there are two other types of list models, the abstract list model and the regular list model, but I'm not entirely sure how to build / implement these models. Is there a good tutorial out there that explains these well? Furthermore - am I correct in my thinking that I need to utilize one of these two models?

Thanks folks!
Vibhatha Lakmal
Greenhorn

Joined: Aug 29, 2012
Posts: 4
I think you want to update the list you have created after you enter some value to the list.

So I also wanted to do the same so I tried this code in order to get it done. It updates the JList in runtime. I do this by means of saving entered data to a text file and read it and updates the JLists...
I hope it would help you a bit...




Try this ...I hope it would help you


all I care is learn something from everyone...
"If there is a day, I could live, Single breath,I could take I take all the things into ma head "--edited Laid to Rest-Lamb of God...
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1076
    
  10

You can go through the tutorial to understand all about lists and models.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Joe Pettit
Ranch Hand

Joined: Aug 16, 2012
Posts: 33

Vibhatha Lakmal wrote:I think you want to update the list you have created after you enter some value to the list.

So I also wanted to do the same so I tried this code in order to get it done. It updates the JList in runtime. I do this by means of saving entered data to a text file and read it and updates the JLists...
I hope it would help you a bit...



Try this ...I hope it would help you


Thanks Vibhatha - I modified some pieces of your code to work in my project and everything seems to work perfect, I appreciate your help!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JList Model Creation / Update