ah well about that according to some things i read about calculating like that it isn't always exact since there are numeric errors, but every language is like tha if i'm not mistaken, however using the currentTimeMillis() should be accurate enough haha i don't really need it to have dead exact accuracy i just don't know why it isn't behaving the way it should.
maybe i'm not explaining myself right. so i will do it in a different way:
public void tempori(){
try{
currentTime = System.currentTimeMillis();
while(true){
area.requestFocus();
while(!s.equalsIgnoreCase("que")){
if (!s.equalsIgnoreCase("")){
elapsedTime = System.currentTimeMillis() - currentTime;
if (elapsedTime==1000){
elapsedTime=0L;
sec+=1;
}
field.setText(String.format("%d:%d",sec,elapsedTime));
}
s = area.getText().trim();
}
}
}catch(Exception ex){
System.out.println(ex.getMessage());
}
}
i get the total time at that moment in currentTime, enter the infinite loop and then check for the conditions to start the calculations
elapsedTime = System.currentTimeMillis() - currentTime;
when that happens it shouldn't be over 1000 so it should be that at one point and enter the If statement but it never does, i changed the if statement just in case it went over 1000 due to the numeric error when looping for it to be >= instead of == but if i do that, the sec variable goes wild.
on the other problems which i seriously don't understand is that sometimes (a lot of the times) when i run the program and i type anything, no matter what it is, the throws a null exception and the program just doesn't work anymore so i have to stop it and re-run it, sometimes it does it again and sometimes it doesn't, i'd like help on that as well.