import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.applet.Applet; import javax.sound.midi.*; public class Akordion2 extends JApplet implements MouseListener{ JButton cNupp=new YmmarguneNupp("C"); Synthesizer synt; MidiChannel kanal; int valjus=100; public Akordion2(){ try{ synt=MidiSystem.getSynthesizer(); synt.open(); kanal=synt.getChannels()[0]; getContentPane().setLayout(null); cNupp.setBounds(10, 10, 30, 30); getContentPane().add(cNupp); cNupp.addMouseListener(this); } catch(Exception ex){ex.printStackTrace();} } public void mousePressed(MouseEvent e){ if(e.getSource()==cNupp){ kanal.noteOn(60, valjus); } } public void mouseReleased(MouseEvent e){ kanal.allNotesOff(); } public void mouseClicked(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public static void main(String[] arg){ JFrame f=new JFrame(); f.add(new Akordion2()); f.setSize(300, 300); f.setVisible(true); } }