在 Jlist 单元格中显示多行 [英] Display multiple lines within a Jlist cell

查看:49
本文介绍了在 Jlist 单元格中显示多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 JList 的单个单元格中显示多行.在 jtable 中,它是通过向表格单元格渲染器添加一个 JTextarea 来实现的.同样,是否有任何代码可以为包含 textarea 的 JList 添加自定义单元格渲染器?如果是的话,你能给我一个相同的代码片段吗?

How can I display multiple lines within a single cell of a JList. In jtable, it is achieved by adding a JTextarea to the table cell renderer. Similiarly, Is there any code to add a custom cell renderer for a JList that holds a textarea? If yes, can you please give me a code snippet for the same?

或者您认为还有其他更好的方法可以在 Jlist 的单元格内显示多行而不是使用 textarea 吗?请帮我!!

Or do you think there is any other better method to display multiple lines within the cell of Jlist instead of using a textarea? please help me!!

推荐答案

除了使用 Swing 组件中的 HTML 代码(例如 Jigar 说),你也可以指定一个 ListCellRenderer 使用 TextArea,就像您在 JTable 中所做的一样.

Beside usage of HTML code in Swing component (like Jigar says), you can also specify a ListCellRenderer that uses a TextArea, exactly like you do in your JTable.

这篇关于在 Jlist 单元格中显示多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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