import java.awt.*; import java.applet.Applet; import java.awt.event.*; public class KeyboardApplet extends Applet { public void init() { System.err.println( System.getProperty( "os.name" ) + " " + System.getProperty( "os.version" ) ); System.err.println( System.getProperty( "java.vendor" ) + " " + System.getProperty( "java.version" ) ); if( System.getProperty( "java.version" ).compareTo( "1.1" ) < 0 ) { System.err.println( "This applet requires Java version 1.1 or greater to run." ); showStatus( "This applet requires Java 1.1 version or greater to run." ); } else { try { final String num_notes = getParameter( "num_notes" ); final String first_note = getParameter( "first_note" ); int numberOfNotes = 8; float firstNote = (float)440.0; if( num_notes instanceof String && num_notes.length() > 0 ) { final Integer temp_num_notes = Integer.decode( num_notes ); if( temp_num_notes instanceof Integer && temp_num_notes.intValue() > 0 ) numberOfNotes = temp_num_notes.intValue(); } if( first_note instanceof String && first_note.length() > 0 ) { final Float temp_first_note = new Float( first_note ); if( temp_first_note instanceof Float && temp_first_note.floatValue() > 0.0 ) firstNote = temp_first_note.floatValue(); } addNotify(); requestFocus(); Keyboard kb; if( numberOfNotes == 12 ) { final int[] keys = { KeyEvent.VK_A, KeyEvent.VK_W, KeyEvent.VK_S, KeyEvent.VK_D, KeyEvent.VK_R, KeyEvent.VK_F, KeyEvent.VK_T, KeyEvent.VK_G, KeyEvent.VK_H, KeyEvent.VK_U, KeyEvent.VK_J, KeyEvent.VK_I, KeyEvent.VK_K }; kb = new Keyboard( this, firstNote, keys ); } else kb = new Keyboard( this, firstNote, numberOfNotes ); add( kb ); kb.requestFocus(); } catch( Exception e ) { System.err.println( "Applet init threw " + e.toString() ); } } } /* public void processEvent( AWTEvent e ) { System.err.println( "Applet event " + e.toString() ); super.processEvent( e ); } */ }