How can I add some padding to a jtextfield?
I’ve tried tf.setMargin(new Insets(5,5,5,5)); which doesn’t have any effect.
How can I add some padding to a jtextfield? I’ve tried tf.setMargin(new Insets(5,5,5,5)); which
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The problem you are having is that the UI is setting its own border on the text field, overriding the margin you set. You can see a warning to this effect in the javadoc of
setMargin().The solution is to let the UI set a border, then squeeze in another border of your own: