import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.applet.Applet; import javax.sound.midi.*; public class Akordion4 extends JApplet implements MouseListener{ int algtoon=68; //Ab, akordioni nuppude vasak serv int kogus=12; int nupuvahe=50; int vasak=10; int yla=10; int nupudiameeter=30; final int kvint=7; JButton[] nupud=new JButton[kogus]; Synthesizer synt; MidiChannel kanal; int valjus=100; public Akordion4(){ try{ synt=MidiSystem.getSynthesizer(); synt.open(); kanal=synt.getChannels()[0]; getContentPane().setLayout(null); for(int i=0; i72){toon-=12;} nupud[i]=new AkordioniNupp(toon); nupud[i].setBounds(vasak+i*nupuvahe, yla, nupudiameeter, nupudiameeter); getContentPane().add(nupud[i]); nupud[i].addMouseListener(this); } } catch(Exception ex){ex.printStackTrace();} } public void mangiKolmkola(int algnoot){ kanal.noteOn(algnoot ,valjus); kanal.noteOn(algnoot+4 ,valjus); kanal.noteOn(algnoot+7 ,valjus); } public void mousePressed(MouseEvent e){ AkordioniNupp nupp=(AkordioniNupp)e.getSource(); mangiKolmkola(nupp.kysiPohitoon()); } 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 Akordion4()); f.setSize(300, 300); f.setVisible(true); } }