[英]DefaultListModel in Java
What is DefaultListModel
in Java? 什么是Java
DefaultListModel
? and What is its purpose? 它的目的是什么? I tried to google it but didn't get any proper explanation for it!
我试图谷歌它,但没有得到任何正确的解释!
It works as a Model
(predefined) for JList
它作为
JList
的Model
(预定义)
Swings follows MVC and DefaultListModel plays its part as M
in MVC. Swings遵循MVC, DefaultListModel在MVC 中扮演
M
角色。
There are 3 ways to create model: 有三种方法可以创建模型:
DefaultListModel DefaultListModel
Everything is pretty much taken care of by language framework. 语言框架几乎可以解决所有问题。
AbstractListModel AbstractListModel上
You manage the data and invoke the "fire" methods. 您管理数据并调用“fire”方法。 For this approach, you must subclass
AbstractListModel
and implement the getSize
and getElementAt
methods inherited from the ListModel
interface. 对于此方法,您必须继承
AbstractListModel
并实现从ListModel
接口继承的getSize
和getElementAt
方法。
You manage everything. 你管理一切。
Here's a link to an example of using ListModel and DefaultListModel, its the second link when you google it. 这是一个使用ListModel和DefaultListModel的示例的链接,它是谷歌时的第二个链接。
http://www.java2s.com/Code/Java/Swing-JFC/AnexampleofJListwithaDefaultListModel.htm http://www.java2s.com/Code/Java/Swing-JFC/AnexampleofJListwithaDefaultListModel.htm
DefaultListModel
is a implementation of the ListModel
that extends from AbstractListModel
. DefaultListModel
是从AbstractListModel
扩展的ListModel
。
Internally, it is backed by List
implementation. 在内部,它由
List
实现支持。
It's intention is to provide a simple implementation of the ListModel
that you can use for modelling simple data models where having to extend from the AbstractListModel
or implement the ListModel
interface would be overkill for accomplishing the same task 它的目的是提供
ListModel
的简单实现,您可以使用它来建模简单的数据模型,其中必须从AbstractListModel
扩展或实现ListModel
接口对于完成相同的任务将是过度的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.