//==========================================================//File:                 SimpleApp.java//Function:             Demonstartes simple GUI starting of a jMusic program//Author:               Andrew R. Brown//Environment           JDK1.1.7//============================================================import java.awt.*;import java.awt.event.*;import java.io.IOException;import jm.JMC;import jm.music.data.*;import jm.midi.*;import jm.util.Write;public class SimpleGUI_f extends Frame implements ActionListener, JMC{		//attributes	FileDialog fd;		////////////////	// simple main method called when the class in run	///////////////	public static void main(String[] args) {		new SimpleGUI_f();	}		////////////	// constructor	////////////	public SimpleGUI_f() {		//give the window a name		super("A simple GUI interface for jMusic");				//add the button		Button composeBtn = new Button("Compose");		composeBtn.addActionListener(this);		composeBtn.setActionCommand("Create");		this.add(composeBtn);				//display the window		this.pack();									this.show();	}		////////////	// Deal with the button click	////////////	public void actionPerformed(ActionEvent ae){		if (ae.getActionCommand().equals("Create")) {			fd = new FileDialog(this, "Save jMusic MIDI file as...",                                            FileDialog.SAVE);			fd.show();			System.out.println(fd.getFile());			System.out.println(fd.getDirectory());			makeMusic();		}	}		/////////////	// The code that creates the jMusic score	// and writes it as MIDI and jm files.	//////////////	public void makeMusic() {		Score scale = new Score("JMDemo - SimpleGUI");		Part inst = new Part("Piano", 1, 0);		Phrase phr = new Phrase(0.0); 				for(short i=0;i<12;i++){			Note note = new Note((int)((Math.random()*20)+50), C);			phr.addNote(note);		}		inst.addPhrase(phr);		scale.addPart(inst);				//write a MIDI file to disk		Write.midi(scale, fd.getDirectory()+fd.getFile());				//save file to disk		Write.midi(scale, "SimpleGUI.jm");				System.out.println("Done!");	}}