From 5a0be3261a52f6a0849941283487d08212a35983 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 29 Apr 2011 01:16:25 +0200 Subject: Fix some off-by-one painting problems git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@15 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/view/Board.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/jrummikub/view/Board.java') diff --git a/src/jrummikub/view/Board.java b/src/jrummikub/view/Board.java index d0a3173..5fc0390 100644 --- a/src/jrummikub/view/Board.java +++ b/src/jrummikub/view/Board.java @@ -2,6 +2,7 @@ package jrummikub.view; import java.awt.Color; import java.awt.Graphics; +import java.awt.Insets; import javax.swing.ImageIcon; import javax.swing.JPanel; @@ -21,8 +22,15 @@ public class Board extends JPanel implements IBoard { @Override protected void paintComponent(Graphics g) { - for(int x = 0; x < getWidth(); x += background.getIconWidth()) { - background.paintIcon(this, g, x, 0); + Insets insets = getInsets(); + int x = insets.left, y = insets.top, width = getWidth()-insets.left-insets.right, height = getHeight()-insets.top-insets.bottom; + g = g.create(x, y, width, height); + + for(int xpos = 0; xpos < width; xpos += background.getIconWidth()) { + background.paintIcon(this, g, xpos, 0); + } + for(int xpos = -32; xpos < width; xpos += background.getIconWidth()) { + background.paintIcon(this, g, xpos, 75); } // TODO Rest of painting code -- cgit v1.2.3