From 51d1e8c7abe21278bb7d9510f7e607c38bc66bdf Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Wed, 26 Jan 2022 16:41:21 +0100 Subject: [PATCH] Add Offset for startStack --- src/main/java/solitaer/Card.java | 3 +++ src/main/java/solitaer/StartStack.java | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/solitaer/Card.java b/src/main/java/solitaer/Card.java index a5b7128..63b1d8e 100644 --- a/src/main/java/solitaer/Card.java +++ b/src/main/java/solitaer/Card.java @@ -1,5 +1,6 @@ package solitaer; +import java.awt.Color; import java.awt.Graphics; import java.awt.Image; import java.util.Objects; @@ -113,6 +114,8 @@ public class Card extends JPanel { // TODO Auto-generated method stub super.paintComponent(g); g.drawImage(getImage(), 0, 0, this.getWidth(), this.getHeight(), this); + g.setColor(Color.black); + g.drawRect(0, 0, this.getWidth()-1, this.getHeight()-1); } } diff --git a/src/main/java/solitaer/StartStack.java b/src/main/java/solitaer/StartStack.java index 2ab0504..66a25c1 100644 --- a/src/main/java/solitaer/StartStack.java +++ b/src/main/java/solitaer/StartStack.java @@ -12,21 +12,26 @@ public class StartStack extends JPanel { private static final long serialVersionUID = 1L; private Image im; private ArrayList stack = new ArrayList(); + + private int offset; public StartStack(int _x, int _y) { super.setLocation(_x, _y); super.setSize(72, 450); super.setOpaque(false); super.setLayout(null); + + offset = 0; } public void addCard(Card _card) { + _card.setLocation(0, offset); stack.add(_card); - System.out.println("dfsfdsf"); addtoPanel(); + offset += 20; } - void addtoPanel() { + private void addtoPanel() { this.removeAll(); for(int i = stack.size()-1; i>=0; i-- ) {