File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JList Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JList Problem" Watch "JList Problem" New topic

JList Problem


Joined: Jan 27, 2005
Posts: 13
Hello !!!

I wanna load a dynamic list of value to a JList... That means the values that contain in the JList is not constants... it may change !!!
so how do i do this ???
Pat Hays
Ranch Hand

Joined: Aug 20, 2004
Posts: 138
Call jList1.setListData(array) again.

Download Java GUI Builder, <a href="" target="_blank" rel="nofollow"></a>
Snoop One

Joined: Mar 14, 2005
Posts: 5
Well you should maybe look in to the model-view-controller architecture of swing.

Very brief intro:

The swing architecture:

So what you need to do is to use a DefaultListModel as your data model and add any changes on the DefaultListModel object.
KR Campbell
Ranch Hand

Joined: Mar 26, 2004
Posts: 124
Reading the API for JList would be a good starting point:

"Simple dynamic-content JList applications can use the DefaultListModel class to store list elements."
KR Campbell
Ranch Hand

Joined: Mar 26, 2004
Posts: 124
Originally posted by Pat Hays:
Call jList1.setListData(array) again.

..perhaps writing a ListDataListener would be a slightly more elegant approach!
I agree. Here's the link:
subject: JList Problem
jQuery in Action, 3rd edition