import javax.sound.midi.*; import javax.swing.*; import java.awt.event.*; public class Noodirakend 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; int korgus=69; //A int valjus=65; //keskmine kanal.noteOn(korgus, valjus); Thread.sleep(1000); kanal.noteOff(korgus); synthesizer.close(); }catch(Exception ex){ ex.printStackTrace(); } } }