By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,694 Members | 1,882 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,694 IT Pros & Developers. It's quick & easy.

Swing JList displaying arraylist

P: 98
hi,

I have an arrayList in my program that I want to display in a Jlist. I need the JList to update his contents when the elements in the arraylist change/ an element is added/deleted/...

I'm lost on how to do this. Passing the arrayList as an array into the Jlistconstructor will just display the elements, but no updates will be made according to the API.

Apparently ListDataListeners should be used, and I don't seem to be able to find a nice simple tutorial on how to create these things.

Any help is appreciated. Thanks!
Oct 22 '09 #1
Share this Question
Share on Google+
2 Replies


P: 98
I thought I should provide some more info.

I have a program on which I have to build a GUI. I may not change anything inside the program. I can get the arrayList to display using a public inspector from the program and this is the only thing I can use to hook it up to a JList.

I have no clue on how to do this in an easy way. I've googled around, finding info on listeners, events, but I don't see a clear solution.
Oct 22 '09 #2

P: 98
Implementing my own version of ListModel holding an Arraylist did the trick.
Oct 22 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.