Search code examples
javaswingcase-insensitivejoptionpane

Making JOptionPane not case sensitive?


I can't seem to find out anywhere but if I remember correctly there was something you could add to the end of a JOptionPane statement to make it case insensitive ? Here's my code, focusing on string a

....  scanner.close();
for (int i = 1; i < lines.size(); i += 2)
{
}

Solution

  • It's not really about JOptionPane, but what happens after it has done its work :-)

    Use equalsIgnoreCase when comparing the two strings.

    if (a.equalsIgnoreCase(answer) && input.equals("instant")) {
                ^^^^^^^^^^
        ...
    }
    else if (a.equalsIgnoreCase(answer) && input.equals("generate")) {
                     ^^^^^^^^^^
        ...
    }