Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DefaultListModel in Java

What is DefaultListModel in Java? and What is its purpose? I tried to google it but didn't get any proper explanation for it!

like image 311
Naruto Avatar asked Oct 30 '12 10:10

Naruto


1 Answers

It works as a Model (predefined) for JList

Swings follows MVC and DefaultListModel plays its part as M in MVC.

There are 3 ways to create model:

  • DefaultListModel

    Everything is pretty much taken care of by language framework.

  • AbstractListModel

    You manage the data and invoke the "fire" methods. For this approach, you must subclass AbstractListModel and implement the getSize and getElementAt methods inherited from the ListModel interface.

  • ListModel

    You manage everything.

like image 118
Azodious Avatar answered Nov 15 '22 11:11

Azodious