I would like to create a JList in Java so that each individual item is formattted using HTML tags, but I'm not clear how to do this or even if this is possible. Does anyone have any suggestions?
Thank you.
I would like to create a JList in Java so that each individual item is formattted using HTML tags, but I'm not clear how to do this or even if this is possible. Does anyone have any suggestions?
Thank you.
Swing supports the use of HTML in many of the controls that display text.
In your case the JList
is actually using a JLabel
to display each item, so you just need the list model to return the string values in the list as HTML and it should all work.
Alternately you can write a javax.swing.ListCellRenderer
that converts the value in the list to HTML.
There's some more info on Swing's HTML support here.