How to prevent text from turning to ellipsis on small buttons in JavaFX?


If I make button relatively small, it's caption turns to ellipsis.

How to turn off this feature?

11/25/2013 10:51:15 AM

Don't let the button go below it's preferred size, then it will never need to elide the text of the button label:

button.setMinSize(Button.USE_PREF_SIZE, Button.USE_PREF_SIZE);

I want to make very small button

You can use any of the below either separately or in combination:

  1. Apply CSS to use a very small font in the button.
  2. Make the label text for the button very short.
  3. Use brian's answer which proposes explicitly setting the ellipse string to empty.
  4. Use a small graphic icon instead of text.

You can use setMinSize as documented above in all cases (if you wish the button not to go below a preferred size truncating or eliding content).

In all cases, if you wish, you can also apply CSS to minimize the padding between the label and button the border.

From your previous comment (I want to use simple captions like "<" and ">"), I think option 2 (Make the label text for the button very short) is what you want.

You may also be interested in Joel's Designing for People Who Have Better Things To Do With Their Lives which would indicate, usability-wise that very small buttons are usually a pretty bad idea.

9/22/2017 5:54:23 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow