diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/jrummikub/view/impl/StoneCollectionPanel.java | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/src/jrummikub/view/impl/StoneCollectionPanel.java b/src/jrummikub/view/impl/StoneCollectionPanel.java index 493b299..a3453d1 100644 --- a/src/jrummikub/view/impl/StoneCollectionPanel.java +++ b/src/jrummikub/view/impl/StoneCollectionPanel.java @@ -25,6 +25,8 @@ import jrummikub.view.IStoneCollectionPanel; class StoneCollectionPanel extends AbstractStonePanel implements IStoneCollectionPanel { private final static ImageIcon BACKGROUND = new ImageIcon( + HandPanel.class.getResource("/jrummikub/resource/felt.png")); + private final static ImageIcon DARK_BACKGROUND = new ImageIcon( HandPanel.class.getResource("/jrummikub/resource/dark_felt.png")); /** * The width of the border of the collection panel @@ -37,7 +39,6 @@ class StoneCollectionPanel extends AbstractStonePanel implements * Creates a new StoneCollection instance */ StoneCollectionPanel() { - setOpaque(false); setBorder(new EmptyBorder(INSET, INSET, INSET, INSET)); addComponentListener(new ComponentAdapter() { @@ -54,27 +55,9 @@ class StoneCollectionPanel extends AbstractStonePanel implements getStonePainter().setScale(height * StonePainter.HEIGHT_SCALE); repaint(); - - /* - * setSize(getStonePainter().getStoneWidth() * selectedStones.size() + 2 - * INSET, getStonePainter().getStoneHeight() + 2 * INSET); - */ } /** - * Sets the height to paint the collected stones in - * - * @param height - * the height in pixels - */ - /* - * void setStoneHeight(int height) { getStonePainter().setScale(height * - * StonePainter.HEIGHT_SCALE); - * - * rescale(); repaint(); //} - */ - - /** * Sets the stones to be shown in the collection * * @param selectedStones @@ -106,16 +89,22 @@ class StoneCollectionPanel extends AbstractStonePanel implements @Override public void paintComponent(Graphics g1) { + for (int xpos = 0; xpos < getWidth(); xpos += BACKGROUND.getIconWidth()) { + for (int ypos = 0; ypos < getHeight(); ypos += BACKGROUND.getIconHeight()) { + BACKGROUND.paintIcon(this, g1, xpos, ypos); + } + } + int width = getStonePainter().getStoneWidth() * selectedStones.size() + 2 * INSET, height = getHeight(); int x = (getWidth() - width) / 2; Graphics2D g = (Graphics2D) g1.create(x, 0, width, height); if (!selectedStones.isEmpty()) { - for (int xpos = 0; xpos < getWidth(); xpos += BACKGROUND.getIconWidth()) { - for (int ypos = 0; ypos < getHeight(); ypos += BACKGROUND + for (int xpos = 0; xpos < width; xpos += DARK_BACKGROUND.getIconWidth()) { + for (int ypos = 0; ypos < height; ypos += DARK_BACKGROUND .getIconHeight()) { - BACKGROUND.paintIcon(this, g, xpos, ypos); + DARK_BACKGROUND.paintIcon(this, g, xpos, ypos); } } |