I’m working with a simple GUI and I’m having a hard time with my text fields.

This is what I’m working with. The one in the right is what it’s supposed to look like, and the left one is what I did. I’ve successfully put the labels Address 1, Address 2, etc. But when I started putting the text fields, it disappeared. I tried using the setSize, setLocation, but nothing works.
The same thing is happening to the upper panel “Paymen Method”, as seen in the expected outcome, there should be a text field. I have them in my codes but they’re not showing up when being run. Help please.
Here’s my codes:
import javax.swing.*;
import java.awt.*;
public class PanelDemo extends javax.swing.JFrame{
private static final int FRAME_WIDTH = 300;
private static final int FRAME_HEIGHT = 350;
private static final int FRAME_X_ORIGIN = 150;
private static final int FRAME_Y_ORIGIN = 250;
public static void main(String[] args){
//Frame
JFrame contentPane = new javax.swing.JFrame();
contentPane.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contentPane.setSize(300,350);
contentPane.setResizable(false);
contentPane.setLayout(new BorderLayout());
//Payment Panel
JPanel paymentPanel = new javax.swing.JPanel();
paymentPanel.setLayout(new BorderLayout());
//paymentPanel.setPreferredSize(new java.awt.Dimension(270, 90));
paymentPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Payment Method", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12)));
////Components inside Payment Panel
////A) Panels: Radio and Details
JPanel radioPanel = new JPanel();
radioPanel.setLayout(new GridLayout(3,1));
JRadioButton Rbutton1 = new JRadioButton("Credit Card");
JRadioButton Rbutton2 = new JRadioButton("E-Funds");
JRadioButton Rbutton3 = new JRadioButton("Check");
Rbutton3.setSelected(true);
ButtonGroup Bgroup = new ButtonGroup();
Bgroup.add(Rbutton1);
Bgroup.add(Rbutton2);
Bgroup.add(Rbutton3);
radioPanel.add(Rbutton1);
radioPanel.add(Rbutton2);
radioPanel.add(Rbutton3);
//I thought of using a panel as a gap, but still didn't work
/*JPanel gap = new JPanel();
gap.setLayout(new BorderLayout());
gap.setPreferredSize(new java.awt.Dimension(10, 90));*/
JPanel detailsPanel = new JPanel();
detailsPanel.setLayout(new GridLayout(2,1));
//detailsPanel
JLabel Accountnum = new JLabel("Account number:");
JTextField Account = new JTextField();
Account.setPreferredSize(new java.awt.Dimension(90, 40));
detailsPanel.add(Accountnum);
detailsPanel.add(Account);
paymentPanel.add(gap, BorderLayout.CENTER);
paymentPanel.add(detailsPanel);
paymentPanel.add(radioPanel);
contentPane.add(paymentPanel, BorderLayout.PAGE_START);
////Address Information Panel
JPanel addressPanel = new JPanel();
addressPanel.setLayout(new BorderLayout());
addressPanel.setSize(new java.awt.Dimension(270, 80));
addressPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Adress Information", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12)));
contentPane.add(addressPanel, BorderLayout.CENTER);
////Components inside the Address Information Panel
////A) Labels (Address 1, Address 2,...)
JPanel InfoLabel = new JPanel();
InfoLabel.setLayout(new GridLayout(5,1));
JLabel address1 = new JLabel("Address 1:");
JLabel address2 = new JLabel("Address 2:");
JLabel city = new JLabel("City:");
JLabel state = new JLabel("State:");
JLabel zip = new JLabel("Zip Code:");
InfoLabel.add(address1);
InfoLabel.add(address2);
InfoLabel.add(city);
InfoLabel.add(state);
InfoLabel.add(zip);
////B)Text Fields
JPanel infotext = new JPanel();
infotext.setLayout(new GridLayout(5,1));
JTextField text1 = new JTextField();
JTextField text2 = new JTextField();
JTextField text3 = new JTextField();
JTextField text4 = new JTextField();
JTextField text5 = new JTextField();
addressPanel.add(InfoLabel);
addressPanel.add(infotext);
JPanel controlPanel = new JPanel();
controlPanel.setLayout(new FlowLayout());
JLabel test = new JLabel("test");
controlPanel.add(test);
contentPane.add(controlPanel, BorderLayout.PAGE_END);
contentPane.setVisible(true);
}
}
I modified your code a little bit to get to a version that does what you need. Basically, all I did was cleaning the way you are using the layout managers. If you expect that you will have to do several such user interfaces then you could try to read the javadocs for the Swing layout managers in order to better understand them.
Here is the working version: