Why dont you just use a YES NO dialog box instead of an input dialog. Looks a lot better and easy. Also, looks like your brackets are in the wrong place. look at this
CODE
private void AddEntryJButtonActionPerformed( ActionEvent event )
{
int answer = JOptionPane.YES_OPTION;
int count = 0;
try{
while (answer == JOptionPane.YES_OPTION )
{
String ar = JOptionPane.showInputDialog("Please, enter artist name");
String cd = JOptionPane.showInputDialog("Enter CD name:");
int n = getNumberOfTracks();
if(n < 0)
{
// user cancelled
continue;
}
if (ar!=null && cd!=null && !ar.trim().equals("") && !cd.trim().equals(""))
//making sure that data has been inputted
{
Album album = new Album(ar, cd, n); //creating new Album object and adding my three variables to it
list.add(album); //adding this Album object to my ArrayList
}
else
{
JOptionPane.showMessageDialog(null, "please enter all required data");
}
answer = JOptionPane.showConfirmDialog(null, "Enter another record?", //if yes, will loop again, if no it will exit
"???", JOptionPane.YES_NO_OPTION);
count++; //increment
}
}
catch (NumberFormatException e)
{
System.err.println("Caught NumberFormatException : "+ e.getMessage());
e.printStackTrace();
}
}
This post has been edited by nick2price: 8 Jun, 2008 - 01:14 PM