import javax.swing.*;
import java.awt.*;
public class CoordinateLayoutTest
{
public static void main(String[] args)
{
//Create Frame and Panel
JFrame mainFrame = new JFrame("TEST");
JPanel first = new JPanel();
//Create Layout and send it the Panel
CoordinateLayout layout = new CoordinateLayout(first);
//Create components
JLabel l1 = new JLabel("First Name:");
JTextField b1 = new JTextField(10);
JLabel l2 = new JLabel("Last Name:");
JTextField b2 = new JTextField(10);
JLabel l3 = new JLabel("Home City:");
JTextField b3 = new JTextField(10);
JLabel l4 = new JLabel("Home State:");
JTextField b4 = new JTextField(10);
JLabel l5 = new JLabel("Account Number:");
JTextField b5 = new JTextField(10);
//Add components
layout.addComponent(l1,5,5);
layout.addComponent(b1,105,5);
layout.addComponent(l2,5,35);
layout.addComponent(b2,105,35);
layout.addComponent(l3,5,65);
layout.addComponent(b3,105,65);
layout.addComponent(l4,5,95);
layout.addComponent(b4,105,95);
layout.addComponent(l5,5,125);
layout.addComponent(b5,105,125);
//Simplify adding components by creating JLabels when you use them
/*
JTextField b1 = new JTextField(10);
JTextField b2 = new JTextField(10);
JTextField b3 = new JTextField(10);
JTextField b4 = new JTextField(10);
JTextField b5 = new JTextField(10);
layout.addComponent(new JLabel("First Name:"),5,5);
layout.addComponent(b1,105,5);
layout.addComponent(new JLabel("Last Name:"),5,35);
layout.addComponent(b2,105,35);
layout.addComponent(new JLabel("Home City:"),5,65);
layout.addComponent(b3,105,65);
layout.addComponent(new JLabel("Home State:"),5,95);
layout.addComponent(b4,105,95);
layout.addComponent(new JLabel("Account Number:"),5,125);
layout.addComponent(b5,105,125);
*/
//Finish creating Frame
mainFrame.setSize(300,300);
mainFrame.setContentPane(first);
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainFrame.setVisible(true);
}
}