|
-
February 22nd, 2000, 04:43 PM
#1
JList - adding rows
Hi all
I want to add/append rows to a Jlist keeping the existing rows. How do I do that ? How do I update a certain row in a Jlist?
I appritiate your help!
Thank you in advance!
Y
vimal
-
March 7th, 2000, 03:00 PM
#2
Re: JList - adding rows
try this:
jlist.getModel().addElement(object);
-
March 7th, 2000, 03:37 PM
#3
Re: JList - adding rows
Just like JTree and JTable, you don't manipulate the JList directly; instead, you manipulate its model. Look at the DefaultListModel class. It has the features you are looking for.
-
June 5th, 2000, 03:09 PM
#4
Re: JList - adding rows
Look at the DefaultListModel. Adding rows is easy, but you must fire an event to update the list model.
The methods to fire change events are protected if I remember correctly. Because of this, you will
have to subclass DefaultListModel so that when you add elements to it you can also fire the change
event.
-
June 6th, 2000, 05:48 PM
#5
Re: JList - adding rows
You can store the data in the vector and populate the JList though it. Every time you want to add new elements, add those into the vector and after removing the elements from the JList, populate it again.
May this will help you.
-
March 16th, 2009, 04:25 AM
#6
Re: JList - adding rows
Try with this:
jList.setModel(new DefaultListModel());
((DefaultListModel)jList.getModel()).addElement(object);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|