Swing JList displaying arraylist

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Gangreen
    New Member
    • Feb 2008
    • 98

    Swing JList displaying arraylist

    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 Jlistconstructo r will just display the elements, but no updates will be made according to the API.

    Apparently ListDataListene rs 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!
  • Gangreen
    New Member
    • Feb 2008
    • 98

    #2
    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.

    Comment

    • Gangreen
      New Member
      • Feb 2008
      • 98

      #3
      Implementing my own version of ListModel holding an Arraylist did the trick.

      Comment

      Working...