Could you describe the generic way of using "Model Interface"/"Default Model Class" used for example in javax.swing.buttonModel/javax.swing.DefaultButtonModel?

Sébastien Alonzo

A Model Interface describes the methods used to access the data of an object like JButton.

A Default Model class is a "generic", concrete implementation of the Model Interface.

You can build your own implementation of the Model Interface or use directly the Default implementation (or subclass it if you want to modify its behaviour).

In some cases, you can find an Abstract Model class which implements some of the Model Interface methods as well as some generic behaviour (such as event handling). In that case the Default Model class usually extends an Abstract Model one (e.g. TableModel, AbstractTableModel and DefaultTableModel).

Just keep in mind that Default Model classes are "ready to use", whereas Model Interfaces and Abstract Model classes require some implementation.

Anyway, in some cases it's much better to build your own Model class instead of the Default one, for performance sake.

[FAQ Manager Note] In particular, you can also write models that wrap or modify existing data. See http://www7.software.ibm.com/vad.nsf/Data/Document2329 for details on how you can create wrappers for existing models.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact