How can I add padding to a jtextfield

后端 未结 6 1739
予麋鹿
予麋鹿 2021-01-01 12:08

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.

6条回答
  •  忘掉有多难
    2021-01-01 12:26

    You can apply this to a textbox already created with a border

    jTextField1.setBorder(BorderFactory.createCompoundBorder(jTextField1.getBorder(), BorderFactory.createEmptyBorder(6, 6, 6, 6)));
    

提交回复
热议问题