From 5406d540d3879b8d754fc52f90501fd90efb4fb2 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 30 May 2011 17:37:39 +0200 Subject: Show winners in score panel git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@322 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/view/impl/ScorePanel.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/jrummikub/view') 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 players; private Iterable 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); } -- cgit v1.2.3