Ok, so I was trying out the newline strategy for JLabels(Newline in JLabel) by using HTML tags and the <br>
tag, in a JList with a custom cell renderer, but after the break the text is cut off. I'm not sure how to solve this.
private static class RanksListCellRenderer extends JPanel implements ListCellRenderer<Rank> {
private JLabel text = new JLabel();
public RanksListCellRenderer() {
super(new FlowLayout(FlowLayout.LEFT));
setOpaque(false);
add(text);
}
@Override
public Component getListCellRendererComponent(JList<? extends Rank> list,
Rank value, int index, boolean isSelected, boolean cellHasFocus) {
if (!isSelected) {
text.setText(value.getRankName());
} else {
text.setText("<html>" + value.getRankName() + "<br> Rank Data:</html>");
}
return this;
}
}