如何列出绑定到 JList?
我有Jlist。我需要来自 List
Mytype的绑定信息
public class MyType {
String _title = "";
String _description = "";
}
I have Jlist. I need binding info from List<MyType>
Mytype
public class MyType {
String _title = "";
String _description = "";
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要将数据绑定到
JList
数据模型 (ListModel
)。You need to bind your data to
JList
data model (ListModel
).如果您的意思是绑定为“如果我更新列表,JList 也会更新,反之亦然”,您正在寻找类似的内容: Beansbinding 或 Glazed Lists。如果您只想将
List
的每个对象显示为JList
中的项目,请覆盖MyType
toString
方法并编写一些不好的代码,如下所示:或者实现您自己的 列表模型。我绝对会建议您使用库而不是重新启动轮子方法。
If you mean binding as "if I update my List the JList will also be updated and vice-versa" you are looking for something like: Beansbinding or Glazed Lists. If you just want to display every object of
List<MyType>
as an item in theJList
, overrideMyType
toString
method and write some bad code such as this:Or implement your own ListModel. I would definitely advice you to go with the libraries instead of the reiventing the wheel approach.
我不太确定我是否理解你的问题,但你在寻找:
I am not quite sure if I understood your question, but are you looking for: