1

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. JLabel covered

    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;
    }
}
Community
  • 1
  • 1
Sarah Szabo
  • 10,345
  • 9
  • 37
  • 60
  • 1
    For better help sooner, post an [SSCCE](http://sscce.org/). – Andrew Thompson Sep 22 '13 at 06:35
  • 1
    @Andrew Thompson I'm guessing I can't post it here, so in a new question then? It seems like a great idea, I'll get to it tomorrow probably, have to do physics tonight. – Sarah Szabo Sep 23 '13 at 04:52
  • It is possible to [edit your own question](http://stackoverflow.com/posts/18939661/edit). See the little line below the tags? `share | edit | delete` (or something like that, depending on rep. and question ownership) – Andrew Thompson Sep 23 '13 at 05:02

0 Answers0