import java.awt.*;
import java.applet.*;

class MyCanvas extends Canvas {
	
         char n = 'x';
         char d = 'x';
         int dval=0;
         int xval=10;
         int line=0;
		 public int amount = 0;
		 public char notes[];

	public MyCanvas()
	{
		notes = new char[4000];
		for(int z=0;z<4000;z++)
			notes[z]='x';


	}

    public void paint(Graphics g)
    {

		xval = 10;
		line =0;


		for(int lineNumber=20;lineNumber<2000;lineNumber+=50)
		{
			for(int q=0;q<=24;q+=6)
				g.drawLine(10,lineNumber+q,346,lineNumber+q);
			for(int i=122;i<=234;i+=112)
				g.drawLine(i,lineNumber,i,lineNumber+24);
		}

		for(int y=0;y=346)
			{
				xval -= 336;
				line++;
			}
		}
	}
}

public class Music extends Applet {

	private Button highE, highF, G, A, B, C, D, lowE, lowF, lowD,lowC,
					play, backspace;

	int xpos, ypos;

	private List type;

	private ScrollPane scalesScroller;
	private MyCanvas scales;

	private GridBagLayout gbLayout;
	private GridBagConstraints gbConstraints;

	private AudioClip lowCwhole, lowChalf, lowCquarter, lowCeigth, lowCsixteenth,
				lowDwhole, lowDhalf, lowDquarter, lowDeigth, lowDsixteenth,
				lowEwhole, lowEhalf, lowEquarter, lowEeigth, lowEsixteenth,
				lowFwhole, lowFhalf, lowFquarter, lowFeigth, lowFsixteenth,
				Gwhole, Ghalf, Gquarter, Geigth, Gsixteenth,
				Awhole, Ahalf, Aquarter, Aeigth, Asixteenth,
				Bwhole, Bhalf, Bquarter, Beigth, Bsixteenth,
				Cwhole, Chalf, Cquarter, Ceigth, Csixteenth,
				Dwhole, Dhalf, Dquarter, Deigth, Dsixteenth,
				highEwhole, highEhalf, highEquarter, highEeigth, highEsixteenth,
				highFwhole, highFhalf, highFquarter, highFeigth, highFsixteenth;




	public void init()
	{
		
		gbLayout = new GridBagLayout();
		setLayout(gbLayout);

		gbConstraints = new GridBagConstraints();

		highE = new Button("E");
		highF = new Button("F");
		G = new Button("G");
		A = new Button("A");
		B = new Button("B");
		C = new Button("C");
		D = new Button("D");
		lowE = new Button("E");
		lowF = new Button("F");
		lowD = new Button("D");
		lowC = new Button("C");
		play = new Button("Play");
		backspace = new Button("Backspace");

		type = new List(5, false);
		type.addItem("whole");
		type.addItem("half");
		type.addItem("quarter");
		type.addItem("eigth");
		type.addItem("sixteenth");

		scales = new MyCanvas();
		scales.setSize(356, 2000);
		scalesScroller = new ScrollPane();
		scalesScroller.add(scales);
		scalesScroller.setSize(356,300);


		gbConstraints.weightx = 1;
		gbConstraints.weighty = 1;

		gbConstraints.fill = GridBagConstraints.BOTH;
		addComponent(scalesScroller,gbLayout,gbConstraints,0,0,2,15);


		gbConstraints.fill = GridBagConstraints.HORIZONTAL;

		gbConstraints.weighty = 0;
		gbConstraints.weightx = 0;

		
		addComponent(type,gbLayout,gbConstraints,3,2,1,5);
		addComponent(play,gbLayout,gbConstraints,0,2,1,1);
		addComponent(backspace,gbLayout,gbConstraints,1,2,1,1);

		addComponent(highF,gbLayout,gbConstraints,0,3,1,1);
		addComponent(highE,gbLayout,gbConstraints,1,3,1,1);
		addComponent(D,gbLayout,gbConstraints,2,3,1,1);
		addComponent(C,gbLayout,gbConstraints,3,3,1,1);
		addComponent(B,gbLayout,gbConstraints,4,3,1,1);
		addComponent(A,gbLayout,gbConstraints,5,3,1,1);
		addComponent(G,gbLayout,gbConstraints,6,3,1,1);
		addComponent(lowF,gbLayout,gbConstraints,7,3,1,1);
		addComponent(lowE,gbLayout,gbConstraints,8,3,1,1);
		addComponent(lowD,gbLayout,gbConstraints,9,3,1,1);
		addComponent(lowC,gbLayout,gbConstraints,10,3,1,1);

		gbConstraints.weighty = 0;

	
		lowCwhole = getAudioClip(getDocumentBase(), "Cwhole.au");
		lowChalf = getAudioClip(getDocumentBase(), "Chalf.au");
		lowCquarter = getAudioClip(getDocumentBase(), "Cquarter.au");
		lowCeigth = getAudioClip(getDocumentBase(), "Ceigth.au");
		lowCsixteenth = getAudioClip(getDocumentBase(), "Csixteenth.au");
		lowDwhole = getAudioClip(getDocumentBase(), "Dwhole.au");
		lowDhalf = getAudioClip(getDocumentBase(), "Dhalf.au");
		lowDquarter = getAudioClip(getDocumentBase(), "Dquarter.au");
		lowDeigth = getAudioClip(getDocumentBase(), "Deigth.au");
		lowDsixteenth = getAudioClip(getDocumentBase(), "Dsixteenth.au");
		lowEwhole = getAudioClip(getDocumentBase(), "Ewhole.au");
		lowEhalf = getAudioClip(getDocumentBase(), "Ehalf.au");
		lowEquarter = getAudioClip(getDocumentBase(), "Equarter.au");
		lowEeigth = getAudioClip(getDocumentBase(), "Eeigth.au");
		lowEsixteenth = getAudioClip(getDocumentBase(), "Esixteenth.au");
		lowFwhole = getAudioClip(getDocumentBase(), "Fwhole.au");
		lowFhalf = getAudioClip(getDocumentBase(), "Fhalf.au");
		lowFquarter = getAudioClip(getDocumentBase(), "Fquarter.au");
		lowFeigth = getAudioClip(getDocumentBase(), "Feigth.au");
		lowFsixteenth = getAudioClip(getDocumentBase(), "Fsixteenth.au");
		Gwhole = getAudioClip(getDocumentBase(), "Gwhole.au");
		Ghalf = getAudioClip(getDocumentBase(), "Ghalf.au");
		Gquarter = getAudioClip(getDocumentBase(), "Gquarter.au");
		Geigth = getAudioClip(getDocumentBase(), "Geigth.au");
		Gsixteenth = getAudioClip(getDocumentBase(), "Gsixteenth.au");
		Awhole = getAudioClip(getDocumentBase(), "Awhole.au");
		Ahalf = getAudioClip(getDocumentBase(), "Ahalf.au");
		Aquarter = getAudioClip(getDocumentBase(), "Aquarter.au");
		Aeigth = getAudioClip(getDocumentBase(), "Aeigth.au");
		Asixteenth = getAudioClip(getDocumentBase(), "Asixteenth.au");
		Bwhole = getAudioClip(getDocumentBase(), "Bwhole.au");
		Bhalf = getAudioClip(getDocumentBase(), "Bhalf.au");
		Bquarter = getAudioClip(getDocumentBase(), "Bquarter.au");
		Beigth = getAudioClip(getDocumentBase(), "Beigth.au");
		Bsixteenth = getAudioClip(getDocumentBase(), "Bsixteenth.au");
		Cwhole = getAudioClip(getDocumentBase(), "highCwhole.au");
		Chalf = getAudioClip(getDocumentBase(), "highChalf.au");
		Cquarter = getAudioClip(getDocumentBase(), "highCquarter.au");
		Ceigth = getAudioClip(getDocumentBase(), "highCeigth.au");
		Csixteenth = getAudioClip(getDocumentBase(), "highCsixteenth.au");
		Dwhole = getAudioClip(getDocumentBase(), "highDwhole.au");
		Dhalf = getAudioClip(getDocumentBase(), "highDhalf.au");
		Dquarter = getAudioClip(getDocumentBase(), "highDquarter.au");
		Deigth = getAudioClip(getDocumentBase(), "highDeigth.au");
		Dsixteenth = getAudioClip(getDocumentBase(), "highDsixteenth.au");
		highEwhole = getAudioClip(getDocumentBase(), "highEwhole.au");
		highEhalf = getAudioClip(getDocumentBase(), "highEhalf.au");
		highEquarter = getAudioClip(getDocumentBase(), "highEquarter.au");
		highEeigth = getAudioClip(getDocumentBase(), "highEeigth.au");
		highEsixteenth = getAudioClip(getDocumentBase(), "highEsixteenth.au");
		highFwhole = getAudioClip(getDocumentBase(), "highFwhole.au");
		highFhalf = getAudioClip(getDocumentBase(), "highFhalf.au");
		highFquarter = getAudioClip(getDocumentBase(), "highFquarter.au");
		highFeigth = getAudioClip(getDocumentBase(), "highFeigth.au");
		highFsixteenth = getAudioClip(getDocumentBase(), "highFsixteenth.au");




		

	}

	public boolean action(Event e, Object o)
	{
		if(e.target instanceof Button) 
		{
			if (e.target == highF) {
				scales.notes[(scales.amount * 2)] = 'F';
				scales.notes[(scales.amount * 2)+1] = checkDuration();
			}
			else if (e.target == highE) {
				scales.notes[(scales.amount * 2)] = 'E';
				scales.notes[(scales.amount * 2)+1] = checkDuration();
			}
			if (e.target == D) {
				scales.notes[(scales.amount * 2)] = 'D';
				scales.notes[(scales.amount * 2)+1] = checkDuration();
			}
			if (e.target == C) {
				scales.notes[(scales.amount * 2)] = 'C';
				scales.notes[(scales.amount * 2)+1] = checkDuration();
			}
			if (e.target == B) {
				scales.notes[(scales.amount * 2)] = 'b';
				scales.notes[(scales.amount * 2)+1] = checkDuration();
			}
			if (e.target == A) {
				scales.notes[(scales.amount * 2)] = 'a';
				scales.notes[(scales.amount * 2)+1] = checkDuration();
			}
			if (e.target == G) {
				scales.notes[(scales.amount * 2)] = 'g';
				scales.notes[(scales.amount * 2)+1] = checkDuration();
			}
			if (e.target == lowF) {
				scales.notes[(scales.amount * 2)] = 'f';
				scales.notes[(scales.amount * 2)+1] = checkDuration();
			}
			if (e.target == lowE) {
				scales.notes[(scales.amount * 2)] = 'e';
				scales.notes[(scales.amount * 2)+1] = checkDuration();
			}
			if (e.target == lowD) {
				scales.notes[(scales.amount * 2)] = 'd';
				scales.notes[(scales.amount * 2)+1] = checkDuration();
			}
			if (e.target == lowC) {
				scales.notes[(scales.amount * 2)] = 'c';
				scales.notes[(scales.amount * 2)+1] = checkDuration();
			}



			if((e.target != backspace) && (e.target != play)) {
				scales.amount++;
				scales.repaint();
			}

			if(e.target == backspace) {
				scales.amount--;
				scales.repaint();
			}

			if(e.target == play) {
				for(int j=0;j