[英]How do I bind to this JList so I can change what gets displayed to the user?
I have a JList which i want to use to display a list a caches that are added in from another form, I've got this working and I want to be able to add the caches directly to the list... Is there a way to change what gets displayed to the user?我有一个 JList ,我想用它来显示一个从另一个表单添加的缓存列表,我已经完成了这项工作,我希望能够将缓存直接添加到列表中......有没有办法更改向用户显示的内容? or would it simply be a case of making to the toString method of my object what i want to be displayed?还是只是对我的 object 的 toString 方法制作我想要显示的内容?
public void update(Observable o, Object arg)
{
GeoGolfHole hole = (GeoGolfHole)arg;
model.add(0, hole);
jlHolesInGame.setText(Integer.toString(model.getSize()));
}
You can create a new ListCellRenderer to render what you want out of the class.您可以创建一个新的 ListCellRenderer 以从 class 中呈现您想要的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.