private void submitMatch() {
    Match m =
        new Match(
            league.getId(),
            new Date(),
            league.getSports().get(sportBox.getSelectedIndex()),
            league.getPlayers().get(player1Box.getSelectedIndex() - 1),
            league.getPlayers().get(player2Box.getSelectedIndex() - 1));
    for (int i = 0; i < player1Score.size(); i++) {
      try {
        if (!player1Score.get(i).getText().equals("")
            && !player2Score.get(i).getText().equals("")) {
          m.addSet(
              new Set(
                  m.getSport(),
                  Integer.parseInt(player1Score.get(i).getText()),
                  Integer.parseInt(player2Score.get(i).getText())));
        }
      } catch (NumberFormatException e) {
        Window.alert("Failed to parse number: " + e.getMessage());
      }
    }
    AsyncCallback<Void> callback =
        new AsyncCallback<Void>() {
          public void onFailure(Throwable caught) {
            Window.alert("Failed to save match.");
          }

          public void onSuccess(Void arg) {
            Spelstegen.showMessage("Match sparad.", false);
            resetPanel();
          }
        };
    ServiceManager.getInstance().saveMatch(m, loggedInPlayer, league, callback);
  }
 private void populatePlayerBox(ListBox playerBox) {
   playerBox.clear();
   playerBox.addItem("Välj en spelare");
   for (Player player : league.getPlayers()) {
     playerBox.addItem(player.getPlayerName());
   }
 }
 private void updatePanel() {
   if ((loggedInPlayer == null)
       || (league == null)
       || (!league.getPlayers().contains(loggedInPlayer))) {
     mainPanel.clear();
     panelIsVisible = false;
     return;
   } else if (!panelIsVisible) {
     populatePanel();
     panelIsVisible = true;
   }
   populatePlayerBox(player1Box);
   populatePlayerBox(player2Box);
 }