Verify a String is in the right format
String newYear = JOptionPane.showInputDialog(null, "Please enter the year for " + newTitle);
if (newYear == null)&&(newYear ==? )
I need help to make sure the user's input is a valid year. The bolded question marks are where i think i need to put something but i think i need to change the string to a int or something before i can check if it is in the proper format, but i don't know how. If you need more of my script to see whats giong on then please say so
thanx
[509 byte] By [
H_Ca] at [2007-11-27 1:56:15]

//user click Insert New DVD on the Edit menu
if (arg == "Insert")
{
//accept new data
String newTitle = JOptionPane.showInputDialog(null, "Please enter the new movie's title");
if (newTitle == null)
{}//if the cancel button is pressed then it does nothing and does not continue to prompt for info
else//if the cancel button is not pressed then it continues like normal
{
String newStudio = JOptionPane.showInputDialog(null, "Please enter the studio for " + newTitle);
if (newStudio == null)
{}//if the cancel button is pressed then it does nothing and does not continue to prompt for info
else//if the cancel button is not pressed then it continues like normal
{
String newYear = JOptionPane.showInputDialog(null, "Please enter the year for " + newTitle);
if (newYear == null)// && (! isValidYear(newYear))
{}//if the cancel button is pressed then it does nothing and does not continue to prompt for info
else//if the cancel button is not pressed then it continues like normal
{
//enlarge arrays
title = enlargeArray(title);
studio = enlargeArray(studio);
year = enlargeArray(year);
//add new data to arrays
title[title.length-1] = newTitle;
studio[studio.length-1] = newStudio;
year[year.length-1] = newYear;
//call sort method
sort(title);
fieldCombo.setSelectedIndex(0);
}//close of newtitle else
}//close of newstudio else
}//close of newyear else
}//close of if user click Insert New DVD on the Edit menu
//checks if the year is valid in newYear
//user clicks Title on the Search submenu
if (arg == "title")
search(arg, title);
//user clicks Studio on the Search submenu
if (arg == "studio")
search(arg, studio);
//user clicks Year on the Search submenu
if (arg == "year")
search(arg, year);
}
//public boolean isValidYear(String year)
//{
//if (year = !valid)
//{
//return false;
//}
//else
//{
// return true;
// }
//}
This is the part i'm having trouble with. The last part with all the // in front of it was the suggested part but it keeps saying its invalid when using a boolean value
H_Ca at 2007-7-12 1:30:21 >
