diff options
Diffstat (limited to 'src/jrummikub')
-rw-r--r-- | src/jrummikub/view/impl/ScorePanel.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/jrummikub/view/impl/ScorePanel.java b/src/jrummikub/view/impl/ScorePanel.java index 8947d17..39ae285 100644 --- a/src/jrummikub/view/impl/ScorePanel.java +++ b/src/jrummikub/view/impl/ScorePanel.java @@ -2,12 +2,15 @@ package jrummikub.view.impl; import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; +import java.awt.image.BufferedImage; import java.util.Iterator; import javax.swing.Box; +import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -20,6 +23,11 @@ import jrummikub.view.IScorePanel; @SuppressWarnings("serial") class ScorePanel extends JPanel implements IScorePanel { + private final static ImageIcon STAR_ICON = new ImageIcon( + ScorePanel.class.getResource("/jrummikub/resource/star.png")); + private final static ImageIcon EMPTY_ICON = new ImageIcon(new BufferedImage( + 16, 16, BufferedImage.TYPE_INT_ARGB)); + private Iterable<PlayerSettings> players; private Iterable<Score> scores; private Score accumulatedScore; @@ -136,7 +144,10 @@ class ScorePanel extends JPanel implements IScorePanel { c.gridwidth = GridBagConstraints.REMAINDER; } + boolean won = score.getWinners().get(i); JLabel scoreLabel = new JLabel(Integer.toString(score.getPoints().get(i))); + scoreLabel.setIcon(won ? STAR_ICON : EMPTY_ICON); + scoreLabel.setFont(scoreLabel.getFont().deriveFont(won ? Font.BOLD : 0)); scoreLabel.setHorizontalAlignment(JLabel.CENTER); innerPanel.add(scoreLabel, c); } @@ -160,8 +171,11 @@ class ScorePanel extends JPanel implements IScorePanel { c.gridwidth = GridBagConstraints.REMAINDER; } + boolean won = accumulatedScore.getWinners().get(i); JLabel scoreLabel = new JLabel(Integer.toString(accumulatedScore .getPoints().get(i))); + scoreLabel.setIcon(won ? STAR_ICON : EMPTY_ICON); + scoreLabel.setFont(scoreLabel.getFont().deriveFont(won ? Font.BOLD : 0)); scoreLabel.setHorizontalAlignment(JLabel.CENTER); innerPanel.add(scoreLabel, c); } |