Why isn’t the sound playing when I click the btnSetTime?

I’m making an alarm clock for myself, because I like making my own software. I’m relatively new to building Java GUI, but I’m pretty experienced in Python Tkinter GUI building.

When I use it, when it’s suppose to ring when the time equals the actual time, it doesn’t make a sound… I tried to find the answer to this problem, but nothing rang up that would actually help.

Here’s the code:

import javax.sound.sampled.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import java.io.File;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Objects;

public class AlarmClock extends JFrame {
    private AlarmClock() {
        Container cp = getContentPane();
        cp.setLayout(new FlowLayout());

        JLabel lblSetTime = new JLabel("Set Time to Ring:");
        cp.add(lblSetTime);
        JTextField txtSetTime = new JTextField("", 3);
        txtSetTime.setEditable(true);
        cp.add(txtSetTime);
        JButton btnSetTime = new JButton("Set Time");
        cp.add(btnSetTime);
        JLabel lblSuccessful = new JLabel();
        cp.add(lblSuccessful);
        //JLabel lblTimeLeft = new JLabel("Time to Alarm:");
        //cp.add(lblTimeLeft);
        //JTextField txtTimeLeft = new JTextField("", 3);
        //txtTimeLeft.setEditable(false);
        //cp.add(txtTimeLeft);

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setTitle("Alarm Clock");
        setSize(300, 100);
        setVisible(true);

        btnSetTime.addActionListener((ActionEvent actionEvent) -> {
            String time = txtSetTime.getText();
            Calendar cal = Calendar.getInstance();
            SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
            String loginTime = sdf.format(cal.getTime());

            File soundFile = new File("Alarm-Clock-Sound.wav");

            if (Objects.equals(time, loginTime)) {
                try {
                    URL url = this.getClass().getClassLoader().getResource("Alarm-Clock-Sound.wav");
                    AudioInputStream audioIn = AudioSystem.getAudioInputStream(url);
                    Clip clip = AudioSystem.getClip();
                    clip.open(audioIn);
                    clip.start();
                } catch (UnsupportedAudioFileException | LineUnavailableException | IOException e) {
                    e.printStackTrace();
                }
            }

            lblSuccessful.setText("Successful!");
        });
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(AlarmClock::new);
    }
}

Any help would be great!! Thank you, all who take interest!! 🙂