i have made a panel/GUI using BlueJ with multiple JLabels and Entry boxes along with a button, however when i execute it the labels appear next to each other and the Confirm button appears on the same row as the last entry box, ive tried changing the coordinates in the code however it doesnt make a difference, how would i go about having each label next to its own entry box and my confirm button at the bottom of the application ?
My code is below:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Log extends JFrame {
public static void main(String[] args){
Log frameTable1= new Log();
}
JPanel panel = new JPanel();
JLabel name = new JLabel("Name", JLabel.LEFT);
JTextField FullName = new JTextField(15);
JPanel panel1 = new JPanel();
JLabel address = new JLabel("Address", JLabel.LEFT);
JTextField Address1line = new JTextField(15);
JTextField postcode = new JTextField(15);
JTextField Destination = new JTextField(15);
JTextField Date = new JTextField(15);
JTextField MilesTravelling = new JTextField(15);
JButton Confirm = new JButton("Confirm");
Log(){
super("Customer GUI");
setSize(300,400);
setLocation(400,250);
panel.setLayout(new FlowLayout());
FullName.setBounds(70,30,150,20);
Address1line.setBounds(70,80,150,20);
postcode.setBounds(70,130,150,20);
Destination.setBounds(70,180,150,20);
Date.setBounds(70,230,150,20);
MilesTravelling.setBounds(70,280,150,20);
Confirm.setBounds(105,290,80,40);
name.setBounds(40,30,150,20);
address.setBounds(40, 80, 150, 20);
getContentPane().add(name);
getContentPane().add(panel);
panel.add(name);
getContentPane().add(address);
getContentPane().add(panel);
panel.add(address);
panel.add(FullName);
panel.add(Address1line);
panel.add(postcode);
panel.add(Destination);
panel.add(Date);
panel.add(MilesTravelling);
panel.add(Confirm);
getContentPane().add(panel);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
}
Thankyou