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.
jewelsea
source share