Beispiel #1
0
  /**
   * Initializes the data that is displayed in this panel.
   *
   * @param servers A list of <code>ServerInfo</code>-objects to be displayed.
   */
  public void initialize(List<ServerInfo> servers) {
    // TODO: This should be added as a filtering rule:
    // Remove servers with an incorrect version from the list:
    Iterator<ServerInfo> it = servers.iterator();
    while (it.hasNext()) {
      ServerInfo si = it.next();
      if (!si.getVersion().equals(FreeCol.getVersion())) {
        it.remove();
      }
    }

    tableModel.setItems(servers);
    setEnabled(true);
    if (servers.size() == 0) {
      connect.setEnabled(false);
    } else {
      table.setRowSelectionInterval(0, 0);
    }
  }
Beispiel #2
0
  /** {@inheritDoc} */
  public void actionPerformed(ActionEvent event) {
    final String command = event.getActionCommand();

    try {
      switch (Integer.valueOf(command).intValue()) {
        case CONNECT:
          ServerInfo si = tableModel.getItem(table.getSelectedRow());
          connectController.joinMultiplayerGame(si.getAddress(), si.getPort());
          break;
        case CANCEL:
          getGUI().removeFromCanvas(this);
          getGUI().showNewPanel();
          break;
        default:
          super.actionPerformed(event);
      }
    } catch (NumberFormatException e) {
      logger.warning("Invalid ActionEvent, not a number: " + command);
    }
  }
Beispiel #3
0
 /** Refreshes the table. */
 public void refreshTable() {
   tableModel.fireTableDataChanged();
 }