A JList
needs an instance of ListModel
to work. This instance could be an instance of DefaultListModel
, but you could create your own ListModel
implementation and use it instead of DefaultListModel
.
BTW, note by the constructors of JList construct a JList with a ListModel that is not an instance of DefaultListModel.
If you know that it is a DefaultListModel
, because that's what you passed when constructing the list, then you can safely cast the returned ListModel
to DefaultListModel
.