I have a stupid question that I'm having trouble finding the solution for. I'm writing a chatroom code and need to assign users usernames. I figured I'd throw a JOptionPane up before they access the chatroom. Here is the little bit of code I threw together for that:
int i = -1;
while(i < 0)
{
String name = JOptionPane.showInputDialog("Enter your username: ");
if (name.length() > 0)
{
i++;
}
else {}
}
When I hit the inner-class it tells me it's got no idea what 'name' is with this error:
Client.java:93: error: cannot find symbol
writer.append(" " + name + ": " + input.getText() + "\n");
^
symbol: variable name
Client.java:94: error: cannot find symbol
output.append(" " + name + ": " + input.getText() + "\n");
^
symbol: variable name
Can someone just give me a quick hand on how to solve that problem? Why can't 'name' carry over to my actionPerformed inner-class?