University student here currently working on a tournament application project, and I've got this current issue with GUI:
My matchmaking algorithm takes the player's numbers and matches the lowest number with the highest, for example if we have 8 players then we will have; P1 vs P8, P2 vs P7 and so on. I am currently trying to display this in a TableView using two columns. This means that column one needs to show P1, and column two needs to show P8 on the same row. I am sadly unable to figure out how to make this work, because the current code stacks the players on top of eachother like this:
My current code for this is as follows:
@FXML
private void initialize() {
playerViewer.setPlaceholder(new Label("Players will be shown here"));
SingleElimTournament tournament = new SingleElimTournament();
for(int i = 1; i < 9; i++) {
tournament.addPlayer(new Player("Player " + i, i));
}
int start = 0; //The id for first player according to a seed
int end = tournament.getPlayerAmount() - 1; //The id for last player according to a seed
while (start < end) {
playerList.add(tournament.getPlayersList().get(start));
playerList.add(tournament.getPlayersList().get(end));
start++; //Moving on to the next match
end--; //Moving on to the next match
}
columnOne.setCellValueFactory(new PropertyValueFactory<Player, String>("name"));
columnTwo.setCellValueFactory(new PropertyValueFactory<Player, String>("name"));
playerViewer.setItems(playerList);
}
What would I need to change for the columns to display the opposing players side-to-side instead of on top of eachother? Any advice is greatly appreciated.