This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes How to display contents of JList or drop down list? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to display contents of JList or drop down list?" Watch "How to display contents of JList or drop down list?" New topic
Author

How to display contents of JList or drop down list?

L Willie
Ranch Hand

Joined: Aug 10, 2008
Posts: 51





i try it,however fail to display the contents.thank and appreciate your help and advise
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43968
    
  33
I think with the contents of that posting, it would sit better on our Swing forum.

Moving.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
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

Joined: Aug 10, 2008
Posts: 51
thank your reply,someone advise me study "Collection Framework".study now.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43968
    
  33
Start here.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to display contents of JList or drop down list?
 
It's not a secret anymore!