Pregunta

I'm looking for a possibility to show a List with comments in Java. So I thought I could use the JList and make an own CellRenderer. The problem is that I want to show the name, the date and the comment in one Item of the list.

How could this be realized with a JList and a CellRenderer? Or do I have to use something else instead of the JList?

¿Fue útil?

Solución

It sounds as if you want a JTable rather than a JList. That will give you different columns where you can put your name, date and comment.

I'm sure you could also solve this using a CellRenderer that is a JPanel on which you put whatever you want, but I'd advise you to try out JTable first.

Otros consejos

If you use a JLabel as the ListCellRenderer component (like DefaultListCellRenderer) you could prefix the text with "<html>" and format the "layout" of the list cells with HTML.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top