Frage

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?

War es hilfreich?

Lösung

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.

Andere Tipps

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top