Note that there are some explanatory texts on larger screens.

plurals
  1. POJTextField with JLabels in Simple GUI
    text
    copied!<p>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...</p> <p><img src="https://i.stack.imgur.com/8AHG9.jpg" alt="enter image description here"></p> <p>Here is my DRIVER:</p> <pre><code> 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); } } </code></pre> <p>Currently I have the buttons at the bottom, but the GUI is just one giant text box. Thanks for the help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload