I have a class which extends JPanel and implements ActionListener.
I am having 2 menuItem. When I implemented the abstract method actionPerformed(ActionEvent e) and used repaint if the event source are the menuItem paint method is not called. What can be the possible reasons?
This is what I am doing inside the ActionListener implemantation
FileInputStream fstream = null;
try {
JFileChooser fc = new JFileChooser();
int returnVal = fc.showOpenDialog(frame);
File file1 = null;
if (returnVal == JFileChooser.APPROVE_OPTION) {
file1 = fc.getSelectedFile();
}
fstream = new FileInputStream(file1);
br = new BufferedReader(new InputStreamReader(new DataInputStream(fstream)));
String str;
while ((str = br.readLine()) != null) {
this.repaint();
String[] strarr = str.split(",");
if (strarr[0].trim().equals("$GPGGA")) {
//System.out.println(str);
String latstringint = strarr[2].trim().substring(0, 2);
double latstringdec = Double.parseDouble(strarr[2].trim().substring(2)) / 60;
if (strarr[3].trim().equals("N")) {
Lat = Integer.parseInt(latstringint) + latstringdec;
} else {
Lat = -(Integer.parseInt(latstringint) + latstringdec);
}
String lonstringint = strarr[4].trim().substring(0, 3);
double lonstringdec = Double.parseDouble(strarr[4].trim().substring(3)) / 60;
if (strarr[5].trim().equals("E")) {
Lon = Integer.parseInt(lonstringint) + lonstringdec;
} else {
Lon = -(Integer.parseInt(lonstringint) + lonstringdec);
}
System.out.println(Lat+"\t"+Lon);
//pos[0]= Lat;
//pos[1]= Lon;
//path.add(pos);
this.repaint();
Thread.sleep(250);
}
if (strarr[0].trim().equals("$GPVTG")) {
heading = Double.parseDouble(strarr[1]);
sog = Double.parseDouble(strarr[7]);
this.repaint();
}
}
} catch (Exception ex) {
Logger.getLogger(MovingMap.class.getName()).log(Level.SEVERE, null, ex);
}