Exemplo n.º 1
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);
    }
  }
Exemplo n.º 2
0
 /**
  * Returns the value at the requested location.
  *
  * @param row The requested row.
  * @param column The requested column.
  * @return The value at the requested location.
  */
 public Object getValueAt(int row, int column) {
   if ((row < getRowCount()) && (column < getColumnCount()) && (row >= 0) && (column >= 0)) {
     ServerInfo si = items.get(row);
     switch (column) {
       case 0:
         return si.getName();
       case 1:
         return si.getAddress();
       case 2:
         return Integer.toString(si.getPort());
       case 3:
         return Integer.toString(si.getCurrentlyPlaying())
             + "/"
             + Integer.toString(si.getCurrentlyPlaying() + si.getSlotsAvailable());
       case 4:
         return Messages.message("gameState." + Integer.toString(si.getGameState()));
       default:
         return null;
     }
   }
   return null;
 }