Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JList Model Creation / Update

 
Joe Pettit
Ranch Hand
Posts: 33
C++ Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can go through the tutorial to understand all about lists and models.
 
Joe Pettit
Ranch Hand
Posts: 33
C++ Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic