#sound

1 messages · Page 1 of 1 (latest)

lost dome
#

does not make a sound

arctic bearBOT
#

<@&987246399047479336> please have a look, thanks.

lost dome
#
import java.awt.Toolkit;

public class Main {
    public static void main(String[] args) {
        Toolkit.getDefaultToolkit().beep();
    }
}
arctic bearBOT
radiant escarp
#

The program might close before it gets the chance to. Try adding a Thread.sleep call afterwards and see if that works

lost dome
#
import java.awt.Toolkit;

public class Main {
    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
            Toolkit.getDefaultToolkit().beep();
        });
        thread.start();
    
    }
}```
arctic bearBOT
lost dome
wraith isle
#

No

#

Don't create a thread

#

Just call thread.sleep

lost dome
#
import java.awt.Toolkit;

public class Main {
    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
            Toolkit.getDefaultToolkit().beep();
        });
        try {
            thread.sleep(1000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
}
arctic bearBOT
lost dome
#

?

lost dome
#

How do I use thread.sleep without creating a thread?

wraith isle
lost dome
wraith isle
#

Yes?

lost dome
#

anyway

rancid venture
#

so you can make it sleep

lost dome
#

I'm sorry, I'm not British, I'm translating what you said from translation, and the translation makes a lot of ridiculous meanings, I wonder if you can just throw the code?

wraith isle
#

Just do that

lost dome
#

public class Main {
    public static void main(String[] args) throws InterruptedException {
        Toolkit.getDefaultToolkit().beep();
        Thread.sleep(1000);

    }
}
arctic bearBOT
lost dome
#

doesn't work

rancid venture
#

e.g. I see here from an old stackoverflow post that windows sounds needs to be on for this to work

lost dome
#

thank you