import javax.sound.midi.*; import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class Noot2 extends Applet implements MouseListener{ MidiChannel kanal; int korgus1, korgus2; public Noot2(){ try{ Synthesizer synthesizer=MidiSystem.getSynthesizer(); synthesizer.open(); kanal=synthesizer.getChannels()[0]; addMouseListener(this); } catch (Exception ex){ ex.printStackTrace(); } } public void mousePressed(MouseEvent e){ korgus1=(getHeight()-e.getY())/2; korgus2=e.getX()/2; kanal.noteOn(korgus1, 50); kanal.noteOn(korgus2, 50); } public void mouseReleased(MouseEvent e){ kanal.noteOff(korgus1); kanal.noteOff(korgus2); } public void mouseClicked(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public static void main(String[] arg){ Frame f=new Frame(); f.add(new Noot2()); f.setSize(300, 300); f.setVisible(true); } }