import javax.sound.midi.*; import javax.swing.*; import java.awt.event.*; public class Noodirakend2 extends JApplet implements ActionListener{ public void init(){ JButton b=new JButton("Mängi"); getContentPane().add(b); b.addActionListener(this); } public void actionPerformed(ActionEvent e){ try{ Synthesizer synthesizer=MidiSystem.getSynthesizer(); synthesizer.open(); MidiChannel kanal=synthesizer.getChannels()[0]; //kanal 0; for(int i=40; i<100; i++){ kanal.noteOn(i, 60); Thread.sleep(200); kanal.noteOff(i); } synthesizer.close(); }catch(Exception ex){ ex.printStackTrace(); } } }