Ejemplo n.º 1
0
 private void updateView() {
   String homeTeamName = (String) homeTeamCombo.getSelectedItem();
   String awayTeamName = (String) awayTeamCombo.getSelectedItem();
   positionGraph.updateGraph(new String[] {homeTeamName, awayTeamName}, data);
   homeTeamPanel.setTeam(data.getTeam(homeTeamName), data);
   awayTeamPanel.setTeam(data.getTeam(awayTeamName), data);
 }
Ejemplo n.º 2
0
  private void changeTables() {
    if (dateOption.isSelected()) {
      List<Result> results = data.getResults((Date) datesCombo.getSelectedItem());
      resultsTable.setModel(new DateResultsTableModel(results, messageResources));

      TableColumnModel columnModel = resultsTable.getColumnModel();

      // Right-justify the home team column so that both home team and away team
      // are lined-up against the score column.
      TableColumn homeTeamColumn = columnModel.getColumn(DateResultsTableModel.HOME_TEAM_COLUMN);
      homeTeamColumn.setCellRenderer(
          new TableRenderer() {

            @Override
            public Component getTableCellRendererComponent(
                JTable table,
                Object value,
                boolean isSelected,
                boolean hasFocus,
                int row,
                int column) {
              JLabel component =
                  (JLabel)
                      super.getTableCellRendererComponent(
                          table, value, isSelected, hasFocus, row, column);
              component.setHorizontalAlignment(JLabel.RIGHT);
              return component;
            }
          });

      homeTeamColumn.setPreferredWidth(160);
      columnModel.getColumn(DateResultsTableModel.AWAY_TEAM_COLUMN).setPreferredWidth(160);
      columnModel.getColumn(DateResultsTableModel.SCORE_COLUMN).setPreferredWidth(10);
    } else {
      String teamName = (String) teamsCombo.getSelectedItem();
      Team team = data.getTeam(teamName);
      List<Result> results = team.getRecord((VenueType) venueCombo.getSelectedItem()).getResults();
      resultsTable.setModel(new TeamResultsTableModel(results, team.getName(), messageResources));

      TableColumnModel columnModel = resultsTable.getColumnModel();
      columnModel.getColumn(TeamResultsTableModel.DATE_COLUMN).setPreferredWidth(50);
      columnModel.getColumn(TeamResultsTableModel.OPPOSITION_COLUMN).setPreferredWidth(200);
      columnModel.getColumn(TeamResultsTableModel.SCORE_COLUMN).setPreferredWidth(10);
      columnModel
          .getColumn(TeamResultsTableModel.SCORE_COLUMN)
          .setCellRenderer(new ScoreRenderer(teamName));
    }
  }