I need help getting everything to close by selecting quit. I have tried several things and none seem to work. the rest of the code works great but I can not get everything to close.
import myGui.*;
import java.util.Vector;
import java.io.*;
import java.awt.event.*;
import java.awt.*;
import java.awt.FileDialog;
class Music
{
public static void main(String[] args)
{
String[] prompts = {"Name of Song", "Name of Artist","Category Of Song"};
String[] whatNext = {"Insert Song Name","Find Song Name","List all Songs","Load from File","Save Songs","Print Store Info","Print Store Owner Info","Quit"};
String[] fields = new String[3];
Vector dataStore = new Vector();
WindowPane screen = new WindowPane();
RadioButtons buttons = new
RadioButtons(screen, "What next?", whatNext);
TextInput Song = new TextInput(screen, "Name of Song?");
DataInputBox input = new DataInputBox(screen, prompts);
DataOutputBox output = new
DataOutputBox(screen, prompts, "The Music Plus Song File");
WritingPad notes = new WritingPad(screen);
screen.showWindowPane();
buttons.showRadioButtons();
String choice = buttons.getNameOfButton();
while (! choice.equals("Quit"))
{
if (choice.equals("Insert Song Name"))
{
input.showDataInputBox();
fields = input.getFields();
dataStore.addElement(new Song(fields[0],fields[1],fields[2]));
}
else if (choice.equals("Find Song Name"))
{
Song.showTextInput();
String nameOfSong = Song.getString();
for (int index=0; index != dataStore.size(); index++)
{
Song datum = (Song)
dataStore.elementAt(index);
if (nameOfSong.equals(datum.getName()))
{
output.showDataOutputBox();
fields[0] = datum.getName();
fields[1] = datum.getArtist();
fields[2] = datum.getCategory();
output.setFields(fields);
}
}
}
else if (choice.equals("List all Songs"))
{
Song datum;
notes.showWritingPad();
for (int index=0; index != dataStore.size(); index++)
{
datum = (Song)
dataStore.elementAt(index);
notes.write(datum.getName()+
" "+datum.getArtist()+
" "+datum.getCategory()+"\n");
}
notes.write("\n");
}
else if (choice.equals("Load from File"))
{
FileDialog file = new
FileDialog(screen,"",FileDialog.LOAD);
file.show();
String filename = file.getFile();
if ( filename != null)
{
try
{
FileInputStream fis = new
FileInputStream(filename);
ObjectInputStream in = new
ObjectInputStream(fis);
Vector newStore = (Vector)in.readObject();
in.close();
dataStore = newStore;
}
catch (Exception e){}
}
}
else if (choice.equals("Save Songs"))
{
FileDialog file = new
FileDialog(screen, "",FileDialog.SAVE);
file.show();
String filename = file.getFile();
if (filename !=null)
{
try
{
FileOutputStream fos = new
FileOutputStream(filename);
ObjectOutputStream out = new
ObjectOutputStream(fos);
out.writeObject(dataStore);
out.flush();
out.close();
}
catch (IOException e){}
}
}
else if (choice.equals("Print Store Info"))
{
notes.showWritingPad();
notes.write("Music Plus\nMusic Mall\nMusic Country, USA\n\n");
notes.write("\n");
}
else if (choice.equals("Print Store Owner Info"))
{
notes.showWritingPad();
notes.write("Owners of Music Plus:\nMusic People & Friends\n\n");
notes.write("\n");
}
buttons.showRadioButtons();
choice = buttons.getNameOfButton();
}
}
}
thanks for any help.

New Topic/Question
Reply




MultiQuote





|