How do I center a JTextfield
问题 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.CENTER); but to no avail. Any ideas? import java.awt.Color; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JTextField; import javax.swing.JPanel; import java.awt.Container;