Hola, estoy creando una aplicacion en netbeans para activar un programa, cree un contador para poner los dias que estara activo el programa, pero mi problema es que al momento de cerrar el jframe hice que detuviera el tiempo del contador y lo guardara en un txt, pero a la hora de llamar los minutos y segundos del txt solo lo imprime pero no lo inicializa.
Espero y puedan ayudarme.
Aqui el codigo :
private int M = 0, S = 0;
File Guardar
= new File("C:\\Users\\Admin\\Downloads\\Tiempo.txt");
@Override
S--;
if( S == -1){
M = M - 1;
S = 60;
}if( M == -1){
M = 5;
S = S - 0;
}if( M == 1 && S == 1){
Lbl_Aviso.setText("Tu Licencia Esta Por Expirar");
}if( M == 0 && S == 1){
Lbl_Aviso.setText("Tu Licencia Expiro");
M = 0; S = 0;
t.stop();
Pasar();
}
Actualizar();
}
};
public Crono() {
initComponents();
this.setLocationRelativeTo(null);
t
= new Timer(1000, acciones
); if( t.isRunning()){
t.stop();
Cargar();
Actualizar();
t
= new Timer(1000, acciones
); t.start();
}else{
t.start();
}
}
Conectar cc = new Conectar();
public void Guardar(){
try{
if(!Guardar.exists()){
Guardar.createNewFile();
}{
BW.write(Lbl_Cronometro.getText());
BW.close();
}
ex.getMessage();
}
}
private void Cargar(){
try {
if (Guardar.exists()){
Scanner sc = new Scanner(Guardar);
Lbl_Cronometro.setText(sc.nextLine());
sc.close();
}
ex.getMessage();
}
}
private void Actualizar() {
Lbl_Cronometro.setText(Tiempo);
}
private void Lbl_SalirMouseClicked
(java.
awt.
event.
MouseEvent evt
) { if(t.isRunning())
{
t.stop();
Guardar();
}
}