Hi
I need to modify the content of the JList on the fly. So, when I need to
update the JList, I rebuild the list model and re-initiate the JList by
using new operator. I need to resize the JFrame manually to see the new
JList. How should I program it to show the new JList right after I modifying
it?
Is JList a good component for dynamic list content?
Thanks
Knute Johnson - 06 Jan 2008 18:24 GMT
> Hi
>
[quoted text clipped - 7 lines]
>
> Thanks
I suspect that you are having troubles adding and removing components
not really with the JList. But since we can't see your code it is hard
to tell.
JList and the DefaultListModel are really good for adding and removing
elements one at a time. If you are going to completely change the
content of the list maybe another component would work better for you.
I have similar requirement in a program that I am working on and I use a
JTextArea as a list component. Periodically I have to update that
component and I just set new content on it. Also it lives in a
JScrollPane so that I don't have to resize my frame to make it fit if
the content suddenly exceeds the original size.

Signature
Knute Johnson
email s/nospam/knute/
------->>>>>>http://www.NewsDem
a - 06 Jan 2008 22:22 GMT
I am able to add the component to the JList lives on the JPanel. But I have
to resize the JFrame to see the update, if I add the component on the fly.
JTextArea is not bad for adding and showing data dynamically. However, I may
need to show the icons with text together in the future. So, what kind of
component is the best?
Thanks for your reply.
"Knute Johnson" <nospam@rabbitbrush.frazmtn.com>
???????:47811cce$0$27797$b9f67a60@news.newsdemon.com...
> > Hi
> >
[quoted text clipped - 20 lines]
> JScrollPane so that I don't have to resize my frame to make it fit if
> the content suddenly exceeds the original size.
Knute Johnson - 07 Jan 2008 01:01 GMT
> I am able to add the component to the JList lives on the JPanel. But I have
> to resize the JFrame to see the update, if I add the component on the fly.
[quoted text clipped - 3 lines]
>
> Thanks for your reply.
Do you call validate() on the JPanel after adding the component? Are
you doing this on the EDT?

Signature
Knute Johnson
email s/nospam/knute/
------->>>>>>http://www.NewsDem
James - 06 Jan 2008 22:09 GMT
> Hi
>
[quoted text clipped - 7 lines]
>
> Thanks
It is not! JList produces an immutable list. You should have noticed
there is no .addItem method...
Check out classes that implement the ListModel interface, e.g.
DefaultListModel class.

Signature
James
*Note: Remove every other letter for correct email address
Thomas A. Russ - 07 Jan 2008 18:25 GMT
> Hi
>
> I need to modify the content of the JList on the fly. So, when I need to
> update the JList, I rebuild the list model and re-initiate the JList by
> using new operator.
Why not just use the JList setModel or setListData method?

Signature
Thomas A. Russ, USC/Information Sciences Institute