A
a2zasics
Hi,
I am getting a NullPointer error executing the ActionListener below.
Can anyone tell me whats wrong. The same code is working for another
Actionlistener. I am really not getting whats wrong here. I have
commented almost everything i could. Any ideas...
-SP
private class getSummary implements ActionListener {
private int day, month,year;
private String desc, tran;
private int amt;
double sum[], grandSum;
private int i;
public void actionPerformed(ActionEvent event) {
int tfmonth = Integer.parseInt(tf1.getText().trim());
BufferedReader data; // (Declare the variable before the
try {
data = new BufferedReader(new FileReader("rec.txt"));
boolean test = false;
for (i=0;i<=tItems;i++) sum=0;
ta.setText("");
while (!test) {
try {
String s = data.readLine();
ta.append(s+"\n");
test = (s == null);
if (!test) {
//StringTokenizer t = new StringTokenizer(s,"|");
//month = Integer.parseInt(t.nextToken());
//day = Integer.parseInt(t.nextToken());
//year = Integer.parseInt(t.nextToken());
//tran = t.nextToken();
//desc = t.nextToken();
//amt = Integer.parseInt(t.nextToken());
//for (i=0;i<=tItems;i++){
// if((month == tfmonth)&& (tran.equals(tList))){
// sum = sum+amt;
// } else {
// }
//}
} else {
}
} catch (IOException e){
}
}
//for (i=0;i<=tItems;i++){
// ta.append(tList+" "+sum+"\n");
// grandSum = grandSum+sum;
//}
//
//ta.append( "Total "+grandSum+ "\n");
//ta.append("--------------------------------------\n");
//try {
// data.close();
//} catch (IOException e){
// ta.append("ERROR closing rec.txt");
//}
}
catch (FileNotFoundException e) {
ta.append("File rec.txt not found\n");
}
}
}
I am getting a NullPointer error executing the ActionListener below.
Can anyone tell me whats wrong. The same code is working for another
Actionlistener. I am really not getting whats wrong here. I have
commented almost everything i could. Any ideas...
-SP
private class getSummary implements ActionListener {
private int day, month,year;
private String desc, tran;
private int amt;
double sum[], grandSum;
private int i;
public void actionPerformed(ActionEvent event) {
int tfmonth = Integer.parseInt(tf1.getText().trim());
BufferedReader data; // (Declare the variable before the
try {
data = new BufferedReader(new FileReader("rec.txt"));
boolean test = false;
for (i=0;i<=tItems;i++) sum=0;
ta.setText("");
while (!test) {
try {
String s = data.readLine();
ta.append(s+"\n");
test = (s == null);
if (!test) {
//StringTokenizer t = new StringTokenizer(s,"|");
//month = Integer.parseInt(t.nextToken());
//day = Integer.parseInt(t.nextToken());
//year = Integer.parseInt(t.nextToken());
//tran = t.nextToken();
//desc = t.nextToken();
//amt = Integer.parseInt(t.nextToken());
//for (i=0;i<=tItems;i++){
// if((month == tfmonth)&& (tran.equals(tList))){
// sum = sum+amt;
// } else {
// }
//}
} else {
}
} catch (IOException e){
}
}
//for (i=0;i<=tItems;i++){
// ta.append(tList+" "+sum+"\n");
// grandSum = grandSum+sum;
//}
//
//ta.append( "Total "+grandSum+ "\n");
//ta.append("--------------------------------------\n");
//try {
// data.close();
//} catch (IOException e){
// ta.append("ERROR closing rec.txt");
//}
}
catch (FileNotFoundException e) {
ta.append("File rec.txt not found\n");
}
}
}