• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

need help on JList

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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..
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use a DefaultListModel, and it's addElement() method

DefaultListModel listModel = new DefaultListModel();
JList list = new JList(listModel);
for(iterate the array)
{
listModel.addElement(...)
}

then later you just add whatever you want to the listModel
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic