@Override public void focusLost(final FocusEvent e) { final Object source = e.getSource(); if (source instanceof FTextField) { // the text box final FTextField nField = (FTextField) source; final String newName = nField.getText().trim(); if (index == 0 && !StringUtils.isBlank(newName) && StringUtils.isAlphanumericSpace(newName) && prefs.getPref(FPref.PLAYER_NAME) != newName) { prefs.setPref(FPref.PLAYER_NAME, newName); prefs.save(); } lobby.firePlayerChangeListener(index); } }
@Override public void handleEvent(FEvent e) { final Object source = e.getSource(); if (source instanceof FTextField) { // the text box FTextField nField = (FTextField) source; String newName = nField.getText().trim(); if (index == 0 && !StringUtils.isBlank(newName) && StringUtils.isAlphanumericSpace(newName) && prefs.getPref(FPref.PLAYER_NAME) != newName) { prefs.setPref(FPref.PLAYER_NAME, newName); prefs.save(); if (allowNetworking) { screen.firePlayerChangeListener(index); } } } }
String getPlayerName() { return txtPlayerName.getText(); }