Allright. It's me again. :D
This time, I'm making an alarm clock program.
I've already completed the bit that gets and displays the system time:
Date vrijeme = new Date();
int sati = vrijeme.getHours();
int minuti = vrijeme.getMinutes();
int sekunde = vrijeme.getSeconds();
Also made a method that compares that time to the desired alarm time:
public void prikažiVrijeme(){
Variables V1 = new Variables();
trenutnoVrijeme.setText(String.valueOf(V1.sati)+":"+String.valueOf(V1.minuti)+":"+String.valueOf(V1.sekunde));
V1.upamćenoVrijeme = String.valueOf(V1.sati)+":"+String.valueOf(V1.minuti);
traženoVrijemeGUI.setText(sat.getText()+":"+minut.getText());
V1.traženoVrijeme = sat.getText()+":"+minut.getText();
if (provjeraVremena(V1.upamćenoVrijeme, V1.traženoVrijeme)){
// PLAY MP3 HERE
}
}
public boolean provjeraVremena(String upamćeno, String traženo){
boolean provjeravanje = false;
if (upamćeno.equals(traženo)){
provjeravanje = true;
}
return provjeravanje;
}
Tested it with a simple JTextField.setText("It works!");
I used java.util.Timer; to animate the digital clock in the GUI (and also compare times every second).
Is it possible to load an .mp3/.wav file and play it?
Later I'd add an option to select your own .mp3, right now I just want any .mp3 to play.