// TestMyApplet.java //----- to test the class MyApplet in MyApplet.java import java.io.*; public class TestMyApplet extends MyApplet { public static void main(String[ ]args) throws IOException{ printf("Now will call my Constructor ... "); // MyApplet.printf 是 static new TestMyApplet( ); //注意 static 的 method, 無法直接使用非static的東東 System.exit(0); //.. 所以 new 自己, 把工作寫到 Constructor 中 } public TestMyApplet( ) { // Constructor 不是 static print("Hello there"); //.. 就可以使用 MyApplet 中任何 methods println(" You!"); print("print 123 in width 5 =="); printf(123, 5); println("=== is it OK?"); java.applet.AudioClip song = getAudioBoth("images/welcome.wav"); if(song != null) { song.play( ); try { Thread.sleep(1357); } catch(InterruptedException e){;} } } }