In my Java code, I am using GridLayout (line shown in red) in code below:
frame = new JFrame("Contacts Details");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainPanel = new JPanel();
buttonPanel = new JPanel();
mainPanel.setLayout(new GridLayout(9, 3));
buttonPanel.setLayout(new GridLayout(1, 3));
The result was this:
Name [ ] (Text Box for name) City [ ] (Text Box for City) Cell [ ] (Text Box for Phone)
whereas, I expected to get:
Name [ ] (Text Box for name) City [ ] (Text Box for City) Cell [ ] (Text Box for Phone)
If you want to get 3 rows x 3 columns in the GridLayout, you should changed the GridLayout statement to that shown in blue below:
frame = new JFrame("Contacts Details");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainPanel = new JPanel();
buttonPanel = new JPanel();
mainPanel.setLayout(new GridLayout(3, 3));
buttonPanel.setLayout(new GridLayout(1, 3));