import javax.sound.midi.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.*; public class rytmiautomaat1 extends JApplet implements ActionListener{ Sequence sequence; Sequencer sequencer; JButton nupp=new JButton("Mängi"); JCheckBox korda=new JCheckBox("Korda"); JScrollBar sbKordi=new JScrollBar(JScrollBar.VERTICAL, 50, 1, 1, 100); JScrollBar sbKorgus=new JScrollBar(JScrollBar.VERTICAL, 50, 1, 1, 100); JScrollBar sbValjus=new JScrollBar(JScrollBar.VERTICAL, 50, 1, 1, 100); JScrollBar sbTempo=new JScrollBar(JScrollBar.VERTICAL, 560, 1, 300, 1000); //paus //-JScrollBar(objekt.mispidi, algv, X, minv, maxv) int tempo, korgus, valjus, kordi; public void init(){ JPanel labelipaneel=new JPanel(new GridLayout(1, 4)); labelipaneel.add(new JLabel("Kõrgus"), BorderLayout.CENTER); labelipaneel.add(new JLabel("Valjus"), BorderLayout.CENTER); labelipaneel.add(new JLabel("Tempo"), BorderLayout.CENTER); labelipaneel.add(new JLabel("Kordi"), BorderLayout.CENTER); JPanel skrollipaneel=new JPanel(new GridLayout(1, 4)); skrollipaneel.add(sbKorgus, BorderLayout.CENTER); skrollipaneel.add(sbValjus, BorderLayout.CENTER); skrollipaneel.add(sbTempo, BorderLayout.CENTER); skrollipaneel.add(sbKordi, BorderLayout.CENTER); JPanel mangupaneel=new JPanel(new GridLayout(1, 1)); mangupaneel.add(nupp, BorderLayout.CENTER); //mangupaneel.add(korda); korda.setSelected(true); JPanel alumine=new JPanel(new GridLayout(3, 1)); alumine.add(labelipaneel); alumine.add(skrollipaneel); alumine.add(mangupaneel); getContentPane().add(alumine, BorderLayout.SOUTH); getContentPane().add(skrollipaneel, BorderLayout.CENTER); nupp.addActionListener(this); sbTempo.addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { JScrollBar temp1 = (JScrollBar)e.getSource(); tempo = temp1.getValue(); } //-end adjustmentValueChanged }); //-end SbTempo.addAdjustmentListener sbValjus.addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { JScrollBar temp2 = (JScrollBar)e.getSource(); valjus = (int)temp2.getValue(); } //-end adjustmentValueChanged }); //-end SbTempo.addAdjustmentListener sbKorgus.addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { JScrollBar temp3 = (JScrollBar)e.getSource(); korgus = (int)temp3.getValue(); } //-end adjustmentValueChanged }); //-end SbTempo.addAdjustmentListener sbKordi.addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { JScrollBar temp4 = (JScrollBar)e.getSource(); kordi = temp4.getValue(); } //-end adjustmentValueChanged }); //-end SbTempo.addAdjustmentListene } //-end init public void actionPerformed(ActionEvent e){ try{ Synthesizer synthesizer=MidiSystem.getSynthesizer(); synthesizer.open(); MidiChannel kanal=synthesizer.getChannels()[0]; //kanal 0; /** kanal.programChange(helipangaNR, pilliNR) */ for(int i=0; i