Search code examples
javaswingjlistlistcellrenderer

JList with 3 JLabel inside


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?


Solution

  • 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.