Web server info - Chapter 22 Java Media Framework and Java Sound
Chapter 22 Java Media Framework and Java Sound (on CD) 1301 53 54 // constructor for MidiDemo 55 public MidiDemo() 56 { 57 super( “MIDI Demo” ); 58 59 container = getContentPane(); 60 container.setLayout( new BorderLayout() ); 61 62 // synthesizer must be instantiated to enable synthesis 63 midiSynthesizer = new MidiSynthesizer(); 64 65 // make piano keys 66 makeKeys(); 67 68 // add control panel to frame 69 controlPanel = new JPanel( new BorderLayout() ); 70 container.add( controlPanel, BorderLayout.NORTH ); 71 72 makeConfigureControls(); 73 74 // add button panel to frame 75 buttonPanel = new JPanel( new GridLayout( 5, 1 ) ); 76 controlPanel.add( buttonPanel, BorderLayout.EAST ); 77 78 // make GUI 79 makePlaySaveButtons(); 80 makeRecordButton(); 81 makePianoPlayerButton(); 82 83 } // end constructor 84 85 // utility method making piano keys 86 private void makeKeys() 87 { 88 // panel containing keys 89 JPanel keyPanel = new JPanel( null ); 90 container.add( keyPanel, BorderLayout.CENTER ); 91 92 // piano keys 93 noteButton = new JButton[ MAX_KEYS ]; 94 95 // add MAX_KEYS buttons and what note they sound 96 for ( int i = 0; i < MAX_KEYS; i++ ) { 97 98 final int note = i; 99 100 noteButton[ i ] = new JButton(); 101 102 // setting white keys 103 noteButton[ i ].setBackground( Color.white ); 104 Fig. 22.10 MidiDemoprovides the GUI than enables users to interact with the application (part 2 of 14).
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.