I’m making a simple address book GUI and I don’t have a very good grasp of layouts. I want my GUI to look like this…

Here is my DRIVER:
import javax.swing.*;
public class AddressBookGui {
public static void main (String[] args)
{
userInput addressBook = new userInput();
addressBook.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //whenever you hit x you will exit the program
addressBook.setSize(750, 600);
addressBook.setVisible(true);
}
}
This is my USERINPUT class
import java.awt.*;
import javax.swing.*;
public class userInput extends JFrame {
private JButton newEntry;
private JButton deleteEntry;
private JButton editEntry;
private JButton saveEntry;
private JButton cancelEntry;
private FlowLayout layout;
private JTextField lastName;
private JTextField middleName;
private JTextField firstName;
private JTextField phone;
public userInput() {
super("My Address Book"); //sets the title!
Container content = getContentPane();
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout());
newEntry = new JButton("New");
deleteEntry = new JButton("Delete");
editEntry = new JButton("Edit");
saveEntry = new JButton("Save");
cancelEntry = new JButton("Cancel");
buttonPanel.add(newEntry);
buttonPanel.add(deleteEntry);
buttonPanel.add(editEntry);
buttonPanel.add(saveEntry);
buttonPanel.add(cancelEntry);
add(buttonPanel, BorderLayout.SOUTH);
content.setLayout(new BorderLayout());
content.add(buttonPanel, "South");
lastName = new JTextField(10); //set the length to 10.
add(lastName); //adds item1 to the window
firstName = new JTextField(10);
add(firstName);
middleName = new JTextField(10);
add(middleName);
phone = new JTextField(10);
add(phone);
setVisible(true);
}
}
Currently I have the buttons at the bottom, but the GUI is just one giant text box. Thanks for the help.
You need another JPanel to place your labels and text fields.
You may use a more advanced layout manager like GridBagLayout for the panel to organize the components properly.