//==========================================================//File:                 SimpleGUI2.java//Function:             Demonstartes GUI passing of args to a jMusic program//Author:               Andrew R. Brown//Environment           JDK1.1.7//============================================================import java.awt.*;import java.awt.event.*;import jm.JMC;import jm.music.data.*;import jm.music.tools.*;import jm.util.*;public class SimpleGUI2 extends Frame implements ActionListener, JMC{	//////////////	// Attributes shared within the class	//////////////	private TextField fileNameBox;        private Button composeBtn;            ////////////////	// simple main method called when the class in run	///////////////	public static void main(String[] args) {		new SimpleGUI2();	}		////////////	// constructor	////////////	public SimpleGUI2() {		//give the window a name		super("A less simple Application");		//create a panel to put objects on 		Panel p = new Panel();				//add the text field		fileNameBox = new TextField("SimpleGUI_2.mid", 24);		p.add(fileNameBox);				//add the button                composeBtn = new Button("Compose");		composeBtn.addActionListener(this);		p.add(composeBtn);				//put the panel in the frame		this.add(p);				//display the window		this.pack();									this.show();	}		////////////	// Deal with the button click	////////////	public void actionPerformed(ActionEvent ae){		if (ae.getSource() == composeBtn) {			String fn = fileNameBox.getText();				if (fn != null) {					makeMusic(fn);				} else makeMusic("SimpleGUI_2.mid");		}	}		/////////////	// The code that creates the jMusic score	// and writes it as MIDI and jm files.	//////////////	public void makeMusic(String fileName) {		Score score = new Score("JMDemo - SimpleGUI_2", 130);		Part inst = new Part("Music", ICE_RAIN, 1);		Phrase phr = new Phrase(0.0); 				for(short i=0;i<200;i++){			Note note = new Note((int)((Math.random()*20)+50), SQ);			phr.addNote(note);		}		inst.addPhrase(phr);		score.addPart(inst);		Mod.fadeOut(score, 10.0);				//write a MIDI file to disk		Write.midi(score, "SimpleGUI_2.mid");	}}