Java Swing Updating JList

前端 未结 1 1005
夕颜
夕颜 2021-01-23 18:37

I\'d like to know if there is any way that I can update a Jlist after the user adds or removes an item to it and after a user sorts it. Is there any way that I can write a stand

相关标签:
1条回答
  • 2021-01-23 19:38

    Updates should be made to the ListModel, not the Array that was used to create the model.

    However, if you want to refresh the list with completely new items or change the order of the items then you create a new DefaultListModel and use the setModel(...) method of the JList to update the view.

    0 讨论(0)
提交回复
热议问题