I am attempting to create it so the user will type in a keyword and it will execute that case. This works fine, but I would like the user to also be able to write after the keyword and it will still find the correct case. For example, the user might input "SEARCH dogs and cats" and it would run the "SEARCH" case.
I attempted to do have a temporary variable that stored only the "SEARCH" portion of the string, but I received an error that it had to be a constant in the switch statements. Is there a workaround or will I have to use if else statements?
Here is some test code with the error:
switch(textField.getText)
{
case SEARCH: case textField.getText().split(" ", 2)[0]: // Error is occuring on the second case statement
// Statements
break;
case Default:
lblOutput.setText("ERROR: NOT FOUND");
}