|
|
@ -1,5 +1,8 @@ |
|
|
|
package de.tims.leaderboard; |
|
|
|
|
|
|
|
import java.awt.GridBagConstraints; |
|
|
|
import java.awt.GridBagLayout; |
|
|
|
import java.awt.Insets; |
|
|
|
import java.util.List; |
|
|
|
import javax.swing.*; |
|
|
|
|
|
|
@ -44,11 +47,60 @@ public class Leaderboard { |
|
|
|
|
|
|
|
public JPanel buildLeaderboard() { |
|
|
|
JPanel mainPanel = new JPanel(); |
|
|
|
mainPanel.setLayout(new GridBagLayout()); |
|
|
|
|
|
|
|
GridBagConstraints gbc = new GridBagConstraints(); |
|
|
|
|
|
|
|
Player[] top10Players = getTop10Players(); |
|
|
|
|
|
|
|
gbc.gridx = 0; |
|
|
|
gbc.gridy = 0; |
|
|
|
gbc.weightx = 0.5; |
|
|
|
gbc.weighty = 0.1; |
|
|
|
gbc.anchor = GridBagConstraints.LINE_END; |
|
|
|
gbc.insets = new Insets(5, 0, 5, 5); |
|
|
|
mainPanel.add(new JLabel("Platzierung"), gbc); |
|
|
|
|
|
|
|
gbc.gridx = 1; |
|
|
|
gbc.gridy = 0; |
|
|
|
gbc.weightx = 0.0; |
|
|
|
gbc.weighty = 0.1; |
|
|
|
gbc.anchor = GridBagConstraints.LINE_START; |
|
|
|
gbc.insets = new Insets(5, 5, 5, 10); |
|
|
|
mainPanel.add(new JLabel("Name"), gbc); |
|
|
|
|
|
|
|
gbc.gridx = 2; |
|
|
|
gbc.gridy = 0; |
|
|
|
gbc.weightx = 0.5; |
|
|
|
gbc.weighty = 0.1; |
|
|
|
gbc.anchor = GridBagConstraints.LINE_START; |
|
|
|
gbc.insets = new Insets(5, 10, 5, 0); |
|
|
|
mainPanel.add(new JLabel("Punkte"), gbc); |
|
|
|
|
|
|
|
for (int i = 0; i < top10Players.length; i++) { |
|
|
|
mainPanel.add(new JLabel(i + 1 + ". " + top10Players[i].getName() + " " + top10Players[i].getPoints())); |
|
|
|
gbc.gridx = 0; |
|
|
|
gbc.gridy = i + 1; |
|
|
|
gbc.weightx = 0.5; |
|
|
|
gbc.weighty = 0.1; |
|
|
|
gbc.anchor = GridBagConstraints.LINE_END; |
|
|
|
gbc.insets = new Insets(5, 0, 5, 5); |
|
|
|
mainPanel.add(new JLabel((i + 1) + "."), gbc); |
|
|
|
|
|
|
|
gbc.gridx = 1; |
|
|
|
gbc.gridy = i + 1; |
|
|
|
gbc.weightx = 0.0; |
|
|
|
gbc.weighty = 0.1; |
|
|
|
gbc.anchor = GridBagConstraints.LINE_START; |
|
|
|
gbc.insets = new Insets(5, 5, 5, 10); |
|
|
|
mainPanel.add(new JLabel(top10Players[i].getName()), gbc); |
|
|
|
|
|
|
|
gbc.gridx = 2; |
|
|
|
gbc.gridy = i + 1; |
|
|
|
gbc.weightx = 0.5; |
|
|
|
gbc.weighty = 0.1; |
|
|
|
gbc.anchor = GridBagConstraints.LINE_START; |
|
|
|
gbc.insets = new Insets(5, 10, 5, 0); |
|
|
|
mainPanel.add(new JLabel("" + top10Players[i].getPoints()), gbc); |
|
|
|
} |
|
|
|
|
|
|
|
return mainPanel; |
|
|
|