I am trying to make a GUI for a simple program. I simply want a text field so that a user can input some text, but the JTextField will not display in my JPanel, even though both my buttons and labels disply with no problems. any help on how to fix this problem much appreciated. Here is my code.
public static void main(String[] args) {
JFrame frame = new JFrame("David's cube program!");
frame.setVisible(true);
frame.setSize(800,350); // i used some code from
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.add(panel1);
panel1.setLayout(null);
JButton button = new JButton("Click to display moves");
panel1.add(button);
button.setLocation(150, 20);
button.setSize(200,50);
button.addActionListener (new Button1Action());
JLabel textArea = new JLabel("Click the button to run moves!");
panel1.add(textArea);
textArea.setLocation(15, 40);
textArea.setSize(600, 100);
textBox = new JTextField(20);
textBox.setFont(textBox.getFont().deriveFont(20f));
textBox.setLocation(15, 180);
textBox.addActionListener (new TextAction() );
textBox.setVisible(true);
panel1.add(textBox);
JButton button2 = new JButton("Click to change file path");
panel1.add(button2);
button2.setLocation(150, 160);
button2.setSize(200,50);
button2.addActionListener (new Button2Action());
JLabel textArea2 = new JLabel("the textfield should be just above me");
panel1.add(textArea2);
textArea2.setLocation(15, 200);
textArea2.setSize(600, 100);
}