FileDocCategorySizeDatePackage
Objarr.javaAPI DocExample2774Mon Mar 04 12:13:24 GMT 2002None

Objarr

public class Objarr extends Applet implements ActionListener

Fields Summary
Button
createBut
Button
dispNextBut
TextField
T1
TextField
T2
TextField
T3
TextField
T4
Label
L1
Label
L2
Label
L3
int
storeCounter
int
displayCounter
BankAccount
A1
BankAccount[]
store
Constructors Summary
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent ae)

		if (ae.getSource() == createBut)
		{
			// THIS LINE NEEDS CHANGING IF CONSTRUCTOR CHANGES
			A1 = new BankAccount(T1.getText(), Integer.parseInt(T2.getText()));
			T1.setText("");
			T2.setText("");
			T3.setText("");
			T4.setText("Account created");
			for(int i=0; i<100000000; i++);    // delay loop
			T4.setText("");
			
			store[storeCounter] = A1;
			storeCounter++; // updates the index for storing next object
		}		
		
		if (ae.getSource() == dispNextBut)
		{
			T1.setText(store[displayCounter].getName());	
			// ADD CODE TO DISPLAY ACCOUNT NUMBER AND BALANCE
			T4.setText("");
			displayCounter++; // updates the index for displaying next object
			// ADD CODE TO CHECK FOR END OF ARRAY
			// OTHERWISE PROGRAM WILL EVENTUALLY FAIL
		} 
		
				
	
public voidinit()

										// Array to store BankAccount objects
	
	   
	
		createBut = new Button("Create");
		createBut.addActionListener(this);
		add(createBut);
		dispNextBut = new Button ("Display Next account");
		dispNextBut.addActionListener(this);
		add(dispNextBut);
			
		T1=new TextField(12);
		T2=new TextField(12);
		T3=new TextField(12);
		T4=new TextField(12);
		L1=new Label("Name");
		L2=new Label("Account No");
		L3=new Label("Balance");
	
		add(L1);
		add(T1);
		add(L2);
		add(T2);
		add(L3);
		add(T3);
		add(T4);	// LAYOUT MANAGER NEEDED!!
	
	
public voidpaint(java.awt.Graphics g)