audio - Wanting to add a simple sound to a little project with a separate class, in java -
i making little java project, first , started of programming 2 days ago, have pretty no programming knowledge , need it. trying add sound it, @ end, in separate class, , don't know how perform this. (sorry if english bad)
here code:
import java.util.scanner; import java.awt.toolkit; public class counter{ public static void main(string[] args){ scanner scanner = new scanner(system.in); int n; system.out.print("type starting number: "); string sinput = scanner.nextline(); int input = integer.parseint(sinput); system.out.print("type ending number: "); string ainput = scanner.nextline(); int input2 = integer.parseint(ainput); if (input <= input2) { system.out.println("error, invalid input, please try again"); main(args); } else { (n = input; n >= input2; n--) { try { thread.sleep(1000); } catch(interruptedexception ex) { } system.out.print(n + ", "); }; toolkit.getdefaulttoolkit().beep(); try { thread.sleep(1000); } catch(interruptedexception ex) { } system.out.print("boom"); toolkit.getdefaulttoolkit().beep(); return; } } }
java awt (abstract window toolkit) rendering graphics, if want audio support, you'll need other apis. start java sound api: http://www.oracle.com/technetwork/java/index-139508.html
Comments
Post a Comment