Bueno, aunque os podeís hacer una idea con él, no os va a servir ya que he desechado la idea de hacerlo en éste proyecto, pero sí me interesa saber cómo es el código para tenerlo en futuros proyectos, ya que lo que hay por internet lo mezcla todo y no me aclaro del todo.
package controltiempo;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.Timer;
import java.applet.AudioClip;
public void abrir_ventana
(String texto
){ setTitle("Controlador de tiempo");
setBounds(500,100,400,200);
setLocationRelativeTo(null);
boton.setBounds(135,90,130,50);
setLayout(null);
informacion
=new JLabel(texto
); informacion.setBounds(60,-50,300,200);
add(boton);
add(informacion);
setResizable(false);
setVisible(true);
}
}
class Sonido{
public void reproduciendo(){
sonido
=java.
applet.
Applet.
newAudioClip(getClass
().
getResource("/controltiempo/WindowsNotifyMessaging.wav")); sonido.play();
}
}
public class ControlTiempo{
public static void main
(String[] args
) { Sonido s1=new Sonido();
Ventana v1=new Ventana();
v1.abrir_ventana("Le avisaré cuando deba tomarse un descanso");
s1.reproduciendo();
v1.
setExtendedState(JFrame.
ICONIFIED); v1.setVisible(false);
Ventana v2=new Ventana();
v2.abrir_ventana("Descanse del ordenador 10 minutos");
s1.reproduciendo();
v2.
setExtendedState(JFrame.
ICONIFIED); v2.setVisible(false);
Ventana v3=new Ventana();
v3.abrir_ventana("Puede volver a trabajar. ¡Que le cunda!");
s1.reproduciendo();
v3.setVisible(false);
v1.
setExtendedState(JFrame.
NORMAL); v1.setVisible(true);
}
});
}
});
time2.start();
time2.setRepeats(false);
}
});
}
});
time.start();
time.setRepeats(false);
}
});
}
}