Here is a screenshot of my JFrame. This will be the main window to my application.

So the problem is that all the buttons are inline with each other, whereas I want them to be one under the other i.e. Add Contact under Show Contacts.
So how can I do that?
Here is my code for the JFrame.
public class CRUDFrame extends JFrame {
public CRUDFrame(){
super("AppCRUD");
setLayout(new FlowLayout());
JButton button1, button2, button3, button4;
button1 = new JButton(" Show Contacts ");
button2 = new JButton(" Add Contact ");
button3 = new JButton(" Update Number in a Contact ");
button4 = new JButton(" Delete a Contact ");
add(button1);
add(button2);
add(button3);
add(button4);
}
}
`
There have been some good answers centered around ‘use a layout’. This example espouses the same advice, but also introduces the concept of nesting one layout within another. E.G. the
JPanelcontaining theJButtons has aGridLayout. That panel is placed in theNORTHof a panel that is then added to theWESTof the main ‘gui’ panel.The other components are added in order to show how the column of buttons might go together with other components in the main user interface.
Contact.java
Screenshot