I want to make my simple applet as least cluttered as possible. Currently all my delays are like
try
{
TimeUnit.SECONDS.sleep(1);
}
catch(InterruptedException e)
{
}
but its really cluttered. I want to have some sort of function, such as
try
{
TimeUnit.SECONDS.sleep(Delay);
}
catch(InterruptedException e)
{
}
then have it get called like this somehow
delay(3)
Or, just get rid of the try/catch
statement in general. Is that possible?
Just create a method that swallows the try/catch.
public void timeDelay(long t) {
try {
Thread.sleep(t);
} catch (InterruptedException e) {}
}
Anytime you want to sleep, call the method.
public void myMethod() {
someCodeHere();
timeDelay(2000);
moreCodeHere();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With