Click to See Complete Forum and Search --> : JList - adding rows
Yogini Parkhi
February 22nd, 2000, 03:43 PM
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
mjpell
March 7th, 2000, 02:00 PM
try this:
jlist.getModel().addElement(object);
tdrury
March 7th, 2000, 02:37 PM
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.
Franklin
June 5th, 2000, 03:09 PM
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.
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.
reach2arin
March 16th, 2009, 04:25 AM
Try with this:
jList.setModel(new DefaultListModel());
((DefaultListModel)jList.getModel()).addElement(object);
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.