• 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

How to display contents of JList or drop down list?

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator





i try it,however fail to display the contents.thank and appreciate your help and advise
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think with the contents of that posting, it would sit better on our Swing forum.

Moving.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
looks like you may need a refresher course on how things work.

ArrayList list = new ArrayList();
Object[] arrayObject=list.toArray();
private JList receiverID_lst = new JList(arrayObject);

here, arrayObject is empty, ergo, receiverID_lst is also empty.

private DefaultListModel model = new DefaultListModel();
and, later
model.addElement(rs.getString("User_ID"));
all well and good, but means nothing('ether code'), model never being set.

ResultSet rs = stmt.executeQuery....
while(rs.next()){
...
list.add( rs );
...
}
strange bit of code, that lot

receiverID_lst.setListData(arrayObject);
well, arrayObject is still empty (there is no auto-recalculation)

disclaimer: comments from perusal of code only
 
L Willie
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank your reply,someone advise me study "Collection Framework".study now.
 
Campbell Ritchie
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Start here.
 
straws are for suckers. tiny ads are for attractive people.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic