Here i am not able to read the integer value,can anyone suggest me what is the problem in thios code.iam trying to write calculator code here step by stem i chewcking the eroor, while checkig the code whether it will take integer input from butten anfd textfield,here if i remove int cv=Integer.parseInt(t.getText()); code will work fine if add it it is giving error
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
public class ca_today extends Applet implements ActionListener{
TextField t = new TextField(5);
String str[] = {"+","-","/","%","*","<-","1/x","=","C",".","MR","MS"};
Button b[]= new Button[12];
Button b1[]= new Button[10];
Button exit = new Button("EXIT");
String pv,op;
public void init() {
setBackground( Color.CYAN );
t.setBackground(Color.yellow);
Panel p = new Panel();
p.add(t);
t.addActionListener(this);
p.setLayout(new GridLayout(3,6));
for( int i = 0 ; i < 10; i++ ){
b1[i]=new Button(""+i);
p.add(b1[i]);
b1[i].addActionListener(this);
}
for(int j = 0 ; j <12; j++ ){
b[j]=new Button(str[j]);
p.add(b[j]);
b[j].addActionListener(this);
}
p.add(exit);
exit.addActionListener(this);
add(p);
}
public void actionPerformed(ActionEvent a){
int res=0;
String c=a.getActionCommand();
int cv=Integer.parseInt(t.getText());//takes the i/p from textarea
t.setText(""+cv);
}
}