tags:

views:

70

answers:

2

Hi all,

Anyone written a JLabel (extension/util/??) that automatically abbreviates the contents depending on it's preferred/visible size?

much appreciated.

+5  A: 

Doesn't JLabel abbreviate text that can't fit by default?
This code displays only "The quick brown fox jum..." on my install:

public class Driver {
    public static void main(String[] args) {
     final JFrame frame = new JFrame("JLabel Test");
     frame.setSize(160,120);
     frame.getContentPane().add(
      new JLabel("The quick brown fox jumped over the lazy dog.") );
     frame.setVisible(true);
    }
}

Gunslinger47
haha .. i had just noticed that - i had mistaken a bug for JLable not working how it obviously does... sorry for the stupid question!!
pstanton
A: 

For improved swing, before writing your own extensions, I recommend to check SwingLabs. In particular there is a cool JXLabel (although it's not clear what you want that the regular JLabel has not)

Davide
i had a look at their website and there's nothing there too impressive. not sure what relevance your answer has whatsoever.
pstanton
Well, your question was asking for something that was already available in the regular JLabel, so it wasn't really clear what you were looking for. SwingLabs **is very** impressive (maybe the JXLabel is not where they shine best), so it must be the first place to look at when you need something more than plain vanilla Swing.
Davide
sorry, i'm not having a go at you - but i did look at the website and some content was not available (404) while what was available was honestly not that helpful/impressive - so i'm not sure of the relevance....
pstanton