Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filling a JList with data

Does anyone have any good tutorials on how to fill a JList (within a JPanel) with user inputted data. Specifically, I want to add people to a selected roster. Is this a matter of filling it with an ArrayList?

Any help would be much appreciated.

like image 978
TopChef Avatar asked Jan 18 '23 03:01

TopChef


1 Answers

  • create a ListModel which wrapps your java.util.List (e.g. by extending AbstractListModel)
  • configure JList to use this model
  • create and configure a renderer to format/ display the Objects in your list as needed

http://docs.oracle.com/javase/tutorial/uiswing/components/list.html

like image 80
Puce Avatar answered Jan 30 '23 18:01

Puce