Main.java
public void actionPerformed(ActionEvent e) {
			setVisible(false);
			setSize(300, 170);
			setTitle(e.getActionCommand());

			Label[] label = {new Label("Name"), new Label("Address"), new Label("Phone")};
			SpringLayout layout = new SpringLayout();
			panel = new Panel(layout);
			TextField nameF = new TextField();
			TextField addrF = new TextField();
			TextField phoneF = new TextField();

			Button btnOK = new Button("OK");
			Button btnExit = new Button("Exit");

			btnOK.addActionListener(new AddOK(nameF, addrF, phoneF));
			btnExit.addActionListener(new Exit());

			panel.add(label[0]);
			panel.add(nameF);
			panel.add(label[1]);
			panel.add(addrF);
			panel.add(label[2]);
			panel.add(phoneF);
			panel.add(btnOK);
			panel.add(btnExit);

			// component positions
			layout.putConstraint(SpringLayout.WEST, label[0], 10, SpringLayout.WEST, panel);
			layout.putConstraint(SpringLayout.NORTH, label[0], 10, SpringLayout.NORTH, panel);
			layout.putConstraint(SpringLayout.WEST, nameF, 0, SpringLayout.WEST, phoneF);
			layout.putConstraint(SpringLayout.NORTH, nameF, 0, SpringLayout.NORTH, label[0]);
			layout.putConstraint(SpringLayout.EAST, nameF, -10, SpringLayout.EAST, panel);
			layout.putConstraint(SpringLayout.WEST, label[1], 10, SpringLayout.WEST, panel);
			layout.putConstraint(SpringLayout.NORTH, label[1], 10, SpringLayout.SOUTH, label[0]);
			layout.putConstraint(SpringLayout.WEST, addrF, 0, SpringLayout.WEST, phoneF);
			layout.putConstraint(SpringLayout.NORTH, addrF, 0, SpringLayout.NORTH, label[1]);
			layout.putConstraint(SpringLayout.EAST, addrF, -10, SpringLayout.EAST, panel);
			layout.putConstraint(SpringLayout.WEST, label[2], 10, SpringLayout.WEST, panel);
			layout.putConstraint(SpringLayout.NORTH, label[2], 10, SpringLayout.SOUTH, label[1]);
			layout.putConstraint(SpringLayout.WEST, phoneF, 10, SpringLayout.EAST, label[1]);
			layout.putConstraint(SpringLayout.NORTH, phoneF, 0, SpringLayout.NORTH, label[2]);
			layout.putConstraint(SpringLayout.EAST, phoneF, -10, SpringLayout.EAST, panel);
			layout.putConstraint(SpringLayout.WEST, btnOK, -50, SpringLayout.HORIZONTAL_CENTER, panel);
			layout.putConstraint(SpringLayout.NORTH, btnOK, 10, SpringLayout.SOUTH, label[2]);
			layout.putConstraint(SpringLayout.WEST, btnExit, 10, SpringLayout.EAST, btnOK);
			layout.putConstraint(SpringLayout.EAST, btnExit, 50, SpringLayout.HORIZONTAL_CENTER, panel);
			layout.putConstraint(SpringLayout.NORTH, btnExit, 0, SpringLayout.NORTH, btnOK);

			removeAll();
			add(panel);
			setLocationRelativeTo(null);
			validate();
			setVisible(true);
		}
// called when "Add a person" button is pressed from main menu

called when "Add a person" button is pressed from main menu
called when " Add a person " button is pressed from main menu
public void actionPerformed(ActionEvent e) {
			setVisible(false);
			setSize(300, 170);
			setTitle(e.getActionCommand());
			Label[] label = {new Label("Name"), new Label("Address"), new Label("Phone")};
			SpringLayout layout = new SpringLayout();
			panel = new Panel(layout);
			TextField nameF = new TextField();
			TextField addrF = new TextField();
			TextField phoneF = new TextField();
			Button btnOK = new Button("OK");
			Button btnExit = new Button("Exit");
			btnOK.addActionListener(new AddOK(nameF, addrF, phoneF));
			btnExit.addActionListener(new Exit());
			panel.add(label[0]);
			panel.add(nameF);
			panel.add(label[1]);
			panel.add(addrF);
			panel.add(label[2]);
			panel.add(phoneF);
			panel.add(btnOK);
			panel.add(btnExit);
			layout.putConstraint(SpringLayout.WEST, label[0], 10, SpringLayout.WEST, panel);
			layout.putConstraint(SpringLayout.NORTH, label[0], 10, SpringLayout.NORTH, panel);
			layout.putConstraint(SpringLayout.WEST, nameF, 0, SpringLayout.WEST, phoneF);
			layout.putConstraint(SpringLayout.NORTH, nameF, 0, SpringLayout.NORTH, label[0]);
			layout.putConstraint(SpringLayout.EAST, nameF, -10, SpringLayout.EAST, panel);
			layout.putConstraint(SpringLayout.WEST, label[1], 10, SpringLayout.WEST, panel);
			layout.putConstraint(SpringLayout.NORTH, label[1], 10, SpringLayout.SOUTH, label[0]);
			layout.putConstraint(SpringLayout.WEST, addrF, 0, SpringLayout.WEST, phoneF);
			layout.putConstraint(SpringLayout.NORTH, addrF, 0, SpringLayout.NORTH, label[1]);
			layout.putConstraint(SpringLayout.EAST, addrF, -10, SpringLayout.EAST, panel);
			layout.putConstraint(SpringLayout.WEST, label[2], 10, SpringLayout.WEST, panel);
			layout.putConstraint(SpringLayout.NORTH, label[2], 10, SpringLayout.SOUTH, label[1]);
			layout.putConstraint(SpringLayout.WEST, phoneF, 10, SpringLayout.EAST, label[1]);
			layout.putConstraint(SpringLayout.NORTH, phoneF, 0, SpringLayout.NORTH, label[2]);
			layout.putConstraint(SpringLayout.EAST, phoneF, -10, SpringLayout.EAST, panel);
			layout.putConstraint(SpringLayout.WEST, btnOK, -50, SpringLayout.HORIZONTAL_CENTER, panel);
			layout.putConstraint(SpringLayout.NORTH, btnOK, 10, SpringLayout.SOUTH, label[2]);
			layout.putConstraint(SpringLayout.WEST, btnExit, 10, SpringLayout.EAST, btnOK);
			layout.putConstraint(SpringLayout.EAST, btnExit, 50, SpringLayout.HORIZONTAL_CENTER, panel);
			layout.putConstraint(SpringLayout.NORTH, btnExit, 0, SpringLayout.NORTH, btnOK);
			removeAll();
			add(panel);
			setLocationRelativeTo(null);
			validate();
			setVisible(true);
		}
public void actionPerformed ( ActionEvent e ) { setVisible ( false ) ; setSize ( 300 , 170 ) ; setTitle ( e . getActionCommand ( ) ) ; Label [ ] label = { new Label ( "Name" ) , new Label ( "Address" ) , new Label ( "Phone" ) } ; SpringLayout layout = new SpringLayout ( ) ; panel = new Panel ( layout ) ; TextField nameF = new TextField ( ) ; TextField addrF = new TextField ( ) ; TextField phoneF = new TextField ( ) ; Button btnOK = new Button ( "OK" ) ; Button btnExit = new Button ( "Exit" ) ; btnOK . addActionListener ( new AddOK ( nameF , addrF , phoneF ) ) ; btnExit . addActionListener ( new Exit ( ) ) ; panel . add ( label [ 0 ] ) ; panel . add ( nameF ) ; panel . add ( label [ 1 ] ) ; panel . add ( addrF ) ; panel . add ( label [ 2 ] ) ; panel . add ( phoneF ) ; panel . add ( btnOK ) ; panel . add ( btnExit ) ; layout . putConstraint ( SpringLayout . WEST , label [ 0 ] , 10 , SpringLayout . WEST , panel ) ; layout . putConstraint ( SpringLayout . NORTH , label [ 0 ] , 10 , SpringLayout . NORTH , panel ) ; layout . putConstraint ( SpringLayout . WEST , nameF , 0 , SpringLayout . WEST , phoneF ) ; layout . putConstraint ( SpringLayout . NORTH , nameF , 0 , SpringLayout . NORTH , label [ 0 ] ) ; layout . putConstraint ( SpringLayout . EAST , nameF , - 10 , SpringLayout . EAST , panel ) ; layout . putConstraint ( SpringLayout . WEST , label [ 1 ] , 10 , SpringLayout . WEST , panel ) ; layout . putConstraint ( SpringLayout . NORTH , label [ 1 ] , 10 , SpringLayout . SOUTH , label [ 0 ] ) ; layout . putConstraint ( SpringLayout . WEST , addrF , 0 , SpringLayout . WEST , phoneF ) ; layout . putConstraint ( SpringLayout . NORTH , addrF , 0 , SpringLayout . NORTH , label [ 1 ] ) ; layout . putConstraint ( SpringLayout . EAST , addrF , - 10 , SpringLayout . EAST , panel ) ; layout . putConstraint ( SpringLayout . WEST , label [ 2 ] , 10 , SpringLayout . WEST , panel ) ; layout . putConstraint ( SpringLayout . NORTH , label [ 2 ] , 10 , SpringLayout . SOUTH , label [ 1 ] ) ; layout . putConstraint ( SpringLayout . WEST , phoneF , 10 , SpringLayout . EAST , label [ 1 ] ) ; layout . putConstraint ( SpringLayout . NORTH , phoneF , 0 , SpringLayout . NORTH , label [ 2 ] ) ; layout . putConstraint ( SpringLayout . EAST , phoneF , - 10 , SpringLayout . EAST , panel ) ; layout . putConstraint ( SpringLayout . WEST , btnOK , - 50 , SpringLayout . HORIZONTAL_CENTER , panel ) ; layout . putConstraint ( SpringLayout . NORTH , btnOK , 10 , SpringLayout . SOUTH , label [ 2 ] ) ; layout . putConstraint ( SpringLayout . WEST , btnExit , 10 , SpringLayout . EAST , btnOK ) ; layout . putConstraint ( SpringLayout . EAST , btnExit , 50 , SpringLayout . HORIZONTAL_CENTER , panel ) ; layout . putConstraint ( SpringLayout . NORTH , btnExit , 0 , SpringLayout . NORTH , btnOK ) ; removeAll ( ) ; add ( panel ) ; setLocationRelativeTo ( null ) ; validate ( ) ; setVisible ( true ) ; }
called when "Add a person" button is pressed from main menu
called when " Add a person " button is pressed from main menu
// component positions
