Java - How to force resize JCheckBox to prevent clicking the empty space ?
Posted
by Brad
on Stack Overflow
See other posts from Stack Overflow
or by Brad
Published on 2010-06-12T16:06:11Z
Indexed on
2010/06/12
16:13 UTC
Read the original article
Hit count: 258
When i create a JCheckBox in my Swing application i leave some extra space after its label, so if the JCheckBox label is for example 100 pixels width, i make the JCheckBox 120 pixels for safety.
The problem as at runtime, it's not nice that a user can click on the empty space after the JCheckBox label and it can be actually clicked, like this :
I wonder if there is a way to resize the JCheckBox at runtime to exactly fit the text inside it, depending on the font type/size used ?
This seems fancy a bit, but i like to make things look perfect :)
© Stack Overflow or respective owner