2

How would one test if a JLabel, with set size, wouldn't be able to display all the text that it set to display?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433

1 Answers1

5
  1. Make another label that you do not set the size of.
  2. Add the same text to the 2nd label.
  3. Call for the preferred size.
  4. If it is larger than the set size, your text will be truncated.

But the most sensible solution is not to set the sizes of labels in the first place.


See also this example.

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433