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

If I make the button relatively small, the title turns into an ellipsis.

How to disable this feature?

+8
java button javafx
source share
3 answers

Do not let the button go below the preferred size, then it will never need to delete the text of the button label:

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

I want to make a very small button

You can use any of the following, either individually or in combination:

  • Apply CSS to use a very small font in the button.
  • Make the shortcut text for the button very short.
  • Use brian's answer , which suggests explicitly setting an empty ellipse string.
  • Use a small graphic icon instead of text.

You can use setMinSize , as described above in all cases (if you want the button not to fall below the preferred size, truncating or returning content).

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

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

You may also be interested in Joel Designing for the people who do the best with their lives , which indicates the usability of very small buttons, usually a pretty bad idea.

+11
source share

in your label / button you can use the textOverrun property to turn off the ellipsis.

 textOverrun.set(OverrunStyle.CLIP); 

it's probably a little late for you, so I put it here for the lonely wanderers who dig this question up.

+6
source share

It sets ... because there is no room for text. You can use larger buttons or a smaller font, but if you really want the dots to disappear, use button.setEllipsisString(""); but then you just get truncated text.

+4
source share

All Articles