public void setLeagueData(LeagueSeason data) { this.data = data; datesCombo.removeAllItems(); for (Date date : data.getDates()) { datesCombo.addItem(date); } teamsCombo.removeAllItems(); for (String teamName : data.getTeamNames()) { teamsCombo.addItem(teamName); } changeTables(); }
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)); } }
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); }
public void setLeagueData(LeagueSeason data) { this.data = data; homeTeamCombo.removeAllItems(); awayTeamCombo.removeAllItems(); for (String teamName : data.getTeamNames()) { homeTeamCombo.addItem(teamName); awayTeamCombo.addItem(teamName); } awayTeamCombo.setSelectedIndex(1); // Default to different team than home team. }