In your loop, you should iterate through the names list and call equalsIgnoreCase("q") on each element, adding another input dialog each iteration.
consider:
while (names.isEmpty() || !names.get(names.size() - 1).equalsIgnoreCase("q"))
{
names.add(JOptionPane.showInputDialog("Enter type of pie"));
}
And if you'd like to disregard the name of the pie "q":
while (names.isEmpty() || !names.get(names.size() - 1).equalsIgnoreCase("q"))
{
names.add(JOptionPane.showInputDialog("Enter type of pie"));
}
// populates the ArrayList names with the JOptionPane user input
if (!names.isEmpty())
{
names.remove(names.size() - 1);
// remove the last name inputted by the user
// since the only way to terminate the loop is by entering "q",
// you are removing the name of "q" from the list.
}
EDIT:
this is a better implementation since it only adds the names which aren't "q":
String userInput = new String();
while (!userInput.equalsIgnoreCase("q"))
{
userInput = JOptionPane.showInputDialog("Enter type of pie");
if (!userInput.equalsIgnoreCase("q"))
{
names.add(userInput);
}
}
namesis aList, obviously it cannot equal "q"; regardless of case. What exactly are you trying to do??