0

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

  • Try the code [here](http://stackoverflow.com/questions/23408915/trying-to-create-a-gui-using-java-but-not-able-to-implement-them-the-way-i-wante/23415555#23415555) from a similar question. – user1803551 May 02 '14 at 17:04
  • I have had a look at this however it doesnt seem to solve my issue, i dont know if its just me being stupid but whatever i add or change it still has no affect, thankyou for the response though –  May 02 '14 at 17:23
  • What do you change and what is the change? – user1803551 May 02 '14 at 17:27
  • I tried adding the box layout code and that does nothing also on the setbounds the coordinates on the right i change and still that does nothing. –  May 02 '14 at 17:33
  • Why can't you copy the code from there and change the names of th variables? After it works start changing it. – user1803551 May 02 '14 at 17:38

0 Answers0