hey guys this is a gui project i working on. its a stack calculator , main class "Calc.java"builds gui enviroment and sets up the calculator. 2nd class "CalcState.java" was set up to allow one undo , which is kind of trivial.3rd class was "CircStack.java" is the one im having problems with. my idea was that my program allowed for one undo. Variable it was saved to was "laststate" so to allow multiple undos i would save the entire lastState to array. so on and so fourth. anyway its still only allowing me one undo. Can anyone understand me first, secondly can anyone help

Java Code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.math.*;
import javax.swing.undo.UndoManager;

public class Calc extends JApplet  {
 private JTextField T0, T1,T2,T3,T4,T5;
 private JButton enterButton,plusButton,minusButton, multiButton,divisButton,UNDOButton;
private CalcState lastState;
public CircStack cs;


	// *******************BUILD GUI ENVIRO*****
 public void init()
  {
  cs = new CircStack(5);
  	final Container c = getContentPane();
	c.setLayout(new GridLayout (6,2));
	
	T0 = new JTextField();
	c.add(T0);
	// **************CREATE ENTER BUTTON******
	enterButton = new JButton("Enter");
	c.add(enterButton);
	

	enterButton.addActionListener(new ActionListener(){
	public void actionPerformed(ActionEvent e){
	lastState = new CalcState(T0.getText(),T1.getText(),T2.getText(),T3.getText(),T4.getText(),T5.getText());
	cs.push(lastState);
	T4.setText(T3.getText());
	T3.setText(T2.getText());
	T2.setText(T1.getText()); 
	T1.setText(T0.getText());
		}
		});
		
	T1 = new JTextField();
	c.add(T1);
	T1.setEditable(false);
				
	//******************CREATES PLUS BUTTON *****
	
	plusButton = new JButton("+");
	c.add(plusButton);
	plusButton.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent e){
	cs.push(lastState);
	lastState = new CalcState(T0.getText(),T1.getText(),T2.getText(),T3.getText(),T4.getText(),T5.getText());

	setFloat(T0, getFloat(T1)+ getFloat(T0));
	setPopStack();
	}
	});
	T2 = new JTextField();
	c.add(T2);
	T2.setEditable(false);

	//******************Creates MINUS BUTTON*******
	minusButton = new JButton("-");
	c.add(minusButton);
	minusButton.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent e) {
	lastState = new CalcState(T0.getText(),T1.getText(),T2.getText(),T3.getText(),T4.getText(),T5.getText());
	cs.push(lastState);
	setFloat(T0, getFloat(T1)- getFloat(T0));
	setPopStack();
	}
	});

	//******************* Creates Multi Button**********
	T3 = new JTextField();
	c.add(T3);
	T3.setEditable(false);
	multiButton = new JButton("*");
	c.add(multiButton);
	multiButton.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent e){
	lastState = new CalcState(T0.getText(),T1.getText(),T2.getText(),T3.getText(),T4.getText(),T5.getText());
	cs.push(lastState);
	setFloat(T0, getFloat(T1) * getFloat(T0));
	setPopStack();
	}
	});
	
	//**************** Creates Divis Button
	T4 = new JTextField();
	c.add(T4);
	T4.setEditable(false);
	divisButton = new JButton("/");
	c.add(divisButton);
	divisButton.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent e) {
	lastState = new CalcState(T0.getText(),T1.getText(),T2.getText(),T3.getText(),T4.getText(),T5.getText());
	cs.push(lastState);
	setFloat(T0, getFloat(T1) / getFloat(T0));
	setPopStack();
	}
	});
	T5 = new JTextField();
	c.add(T5);	
	T5.setEditable(false);
	
	//****************Creates UNDO Button*************
	UNDOButton = new JButton("UNDO");
	c.add(UNDOButton);
	UNDOButton.addActionListener(new ActionListener() {
	public void actionPerformed(ActionEvent e) {
	
	T0.setText(lastState.T0);
	T1.setText(lastState.T1);
	T2.setText(lastState.T2);
	T3.setText(lastState.T3);
	T4.setText(lastState.T4);
	T5.setText(lastState.T5);	
	setPopStack();
	}
	});
	
	}// end init()
	
	//******************DO COMPUTATION************

	
	// RETURNS A FLOAT FROM A TEXT FIELD
	
	public float getFloat(JTextField t)
	{
	return Float.parseFloat(t.getText());
	}
	// SET TEXT FIELD TO FLOATING POINT NUMBER
	
	public void setFloat(JTextField t, float p)
	{
	t.setText((new Float(p)).toString());
	}
	////***************
		
	public double getDouble(JTextField t)
	{
	return Double.parseDouble(t.getText());
	}
	// SET TEXT FIELD TO FLOATING POINT NUMBER
	
	public void setDouble(JTextField t, float p)
	{
	t.setText((new Double(p)).toString());
	}
	
  //*******POPS STACK UP***********
  public void setPopStack(){
T1.setText(T1.getText());
T2.setText(T2.getText()) ;
T3.setText(T3.getText());
T4.setText(T4.getText());
}

	public static void main(String args[])
	{
		JFrame app = new JFrame("Bilals Calculator");
		JApplet applet = new Calc();
		applet.init();
		app.setContentPane(applet.getContentPane());
		app.setSize(540, 300);
		app.setVisible(true);
		}
		}
Java Code:
public class CalcState {

public String T0,T1,T2,T3,T4,T5;
 
public CalcState(String s0,String s1,String s2,String s3,String s4, String s5) {
	T0=s0;
	T1=s1;
	T2=s2;
	T3=s3;
	T4=s4;
	T5=s5;
	}
public String getString1(){
return T0;
}
public String getString2(){
return T1;
}
public String getString3(){
return T2;
}
public String getString4(){
return T3;
}
public String getString5(){
return T4;
}
public String getString6(){
return T5;
}

}
Java Code:
public class CircStack
	{
	private int nextOpen;
	private int count;
	private int max;
	private CalcState[] c;
public CircStack(int maxUndo)
		{
		max = maxUndo;
		c = new CalcState[maxUndo];
		count = 0;
		nextOpen = 0;
		}
public void push(CalcState t)
	{
	c[nextOpen] = t;
	nextOpen++;
if(nextOpen == c.length)
	{
	nextOpen = 0;
	count++;
	}
	}
	
public CalcState pop(){
if(count == 0) {
	System.out.println("The stack is empty");
	return null;
}
nextOpen --;
if(nextOpen<0){
nextOpen = c.length-1;
}
count--;
return c[nextOpen];
}
}