How do I center a JTextfield

后端 未结 3 1299
伪装坚强ぢ
伪装坚强ぢ 2021-01-13 13:13

I\'m having trouble centering a JTexfield in my program.The Textfield does not appear aligned with the JButton. I\'ve tried using the x.setHoriontalAlignment(JTextfield.CENT

3条回答
  •  灰色年华
    2021-01-13 13:17

    Just use the setBounds attribute.

    Jtextfield.setBounds(x,x,x,x);
    

    The first x moves the TextField to the left or right. The second one moves it up or down. The third is the width and the last is the length.

提交回复
热议问题