将ListCellRenderer应用于JList上的单个单元格 [英] Applying a ListCellRenderer to individual cells on a JList

查看:84
本文介绍了将ListCellRenderer应用于JList上的单个单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将listcellrenderer应用于jlist中的一个单元格?我的代码当前可以很好地应用渲染器,但是我想为每个条目设置一个不同的动态变量.抱歉,这有点含糊..

Is it possible to apply a listcellrenderer to purely one cell in a jlist? My code currently works fine in applying the renderer, but I would like to set a different dynamic variable for each entry. Apologies if this is a little vague..

总结一下-我只想将listcellrenderer应用于列表中的一个单元格,我该怎么做?

So to sum up - I want to apply listcellrenderer to only one cell in a list, how would I do this?

推荐答案

是否可以将listcellrenderer应用于jlist中的一个单元?

Is it possible to apply a listcellrenderer to purely one cell in a jlist?

否,所有单元必须共享同一渲染器.渲染器就是这样工作的.

No, all cells would have to share the same renderer. That's how renderers work.

我的代码当前在应用渲染器时工作正常,但是我想为每个条目设置一个不同的动态变量.

My code currently works fine in applying the renderer, but I would like to set a different dynamic variable for each entry.

这可以做到.渲染器可以根据应渲染的数据状态来更改其渲染单元格的方式.

This can be done. The renderer can change how it renders the cell depending on the state of the data that it's supposed to render.

对不起,抱歉.

Apologies if this is a little vague..

如果您解释更多并显示代码,那总会更好.

It's always better if you explain more and show code.

总而言之-我只想将listcellrenderer应用于列表中的一个单元格,我该怎么做?

So to sum up - I want to apply listcellrenderer to only one cell in a list, how would I do this?

再次使渲染器的行为取决于单元格所保存的值.有关更详细的答案,请考虑创建并发布一个 sscce 并进行更多说明(例如,如何进行不同的渲染?).

Again have the renderer's behavior depend on the value held by the cell. For a more detailed answer, consider creating and posting an sscce and explaining more (e.g., render differently how?).

这篇关于将ListCellRenderer应用于JList上的单个单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆