I use a DefaultListCellRenderer
to render an array of Strings (its not really an array of Strings, its just to explain my question). The getListCellRendererComponent
function take an Array and must print an element of that array in bold. My current idea is to use Html tags (like <b>theElement</b>
) but I have read that this is not good practice. The code below is my current idea.
if (value instanceof ArrayList) {
ArrayList<String> al = (ArrayList<String>) value
String s = "<html><b>" + al.get(0) + "</b></html>\n";
al.remove(0);
for(String c : al)
s += c + "\n";
setText(s);