wood burning stoves 2.0
The moose likes Beginning Java and the fly likes need help on JList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "need help on JList" Watch "need help on JList" New topic

need help on JList

catherine matthews
Ranch Hand

Joined: Jan 22, 2006
Posts: 78
i have a problem in JList... Normally i just set the number items to be dispalyed in the Jlist in arrays,
String methods[] = {"setData", "getId", "getName", "getSalary", "getAge", "toString"};
JList listmeth= new JList(methods);

what if i am not intializing the methods and just applying a call method to do that..
When i click a button i would be able to tokenize words from a file...
i would need to take certain words from the tokenized words and add it into a Jlist... Please help me...I have until the part of tokenizing the words and adding the words i needed to display inside an array.. but do no how to add it into a Jlist..
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
use a DefaultListModel, and it's addElement() method

DefaultListModel listModel = new DefaultListModel();
JList list = new JList(listModel);
for(iterate the array)

then later you just add whatever you want to the listModel
I agree. Here's the link: http://aspose.com/file-tools
subject: need help on JList
jQuery in Action, 3rd edition