3

I am trying to detect whether the text of a JButton fits within the current width, and doesn't overflow like this:

Like this

Is this possible, if so how?

Orange Peel
  • 474
  • 4
  • 19

1 Answers1

1

You can try to check it like this:

if (myBtn.getPreferredSize().width > myBtn.getSize().width)
Rahul Tripathi
  • 161,154
  • 30
  • 262
  • 319