Hi everyone,
I'm trying to create a basic GUI for booking classes in a gym. I'm not very familiar with the grid layout and struggling with creating a 2 column grid.
Here's what I'm trying to achieve: gym.jpg
And here's my grid code so far:
private void createPanel() { setLayout(new GridLayout(4, 1)); JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); JPanel panel3 = new JPanel(); JPanel panel4 = new JPanel(); //Panel 1: member ID field panel1.add(memberIDLabel); panel1.add(memberIDField); panel1.add(courseNameLabel); panel1.add(courseNameField); panel1.add(bookButton); //Panel 4: 'view courses' and 'view members' buttons panel4.add(coursesButton); panel4.add(bookingsButton); //Attaches panels to frame this.add(panel1); this.add(panel2); this.add(panel3); this.add(panel4); }
Any guidance would be much appreciated. Many thanks.