JList
I want to programatically add records to the JList ? How should I do it...
I have something like this
String data ="";
List<StoreData> sdList = callRecords.get(numberField.getText());
for (StoreData sd : sdList)
{
data = sd.CalledNum +" " + sd.amount;
//list.
}
and list is a JList, I want to add the records there and then show it under JScrollPane...
Thanks
[603 byte] By [
Thukrala] at [2007-11-26 21:57:31]

You want to use a DefaultListModel.
Add elements to a collection and when the values are changed
update the DLM with the changes.
http://java.sun.com/docs/books/tutorial/uiswing/components/list.html
listModel = new DefaultListModel();
listModel.addElement("Debbie Scott");
listModel.addElement("Scott Hommel");
listModel.addElement("Alan Sommerer");
list = new JList(listModel);
That worked
String data = "";
List<StoreData> sdList = callRecords.get(numberField.getText());
listModel = new DefaultListModel();
for (StoreData sd : sdList)
{
data = sd.CalledNum + " " + sd.amount;
listModel.addElement(data);
}
list = new JList(listModel);
This is what I did, now how to add this list to the scrollpane which I have it in the GUI...