Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 384
Suzan Cioc Avatar asked Nov 25 '13 10:11

Suzan Cioc


2 Answers

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.

like image 61
jewelsea Avatar answered Nov 01 '22 13:11

jewelsea


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

textOverrun.set(OverrunStyle.CLIP);

this is probably a bit late for you, so i am putting it here for lone wanderers digging up this question.

like image 8
rad i Avatar answered Nov 01 '22 12:11

rad i