diff --git a/src/main/java/solitaer/BaseStack.java b/src/main/java/solitaer/BaseStack.java index a94321d..5e78f37 100644 --- a/src/main/java/solitaer/BaseStack.java +++ b/src/main/java/solitaer/BaseStack.java @@ -24,6 +24,10 @@ public abstract class BaseStack extends JPanel { } offset = 0; } + + public void clearStack() { + stack.clear(); + } public boolean stackIsEmpty() { return stack.isEmpty(); diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 7c9e70a..9a4bc87 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -42,7 +42,7 @@ public class SolitaerGamePanel extends JPanel { this.add(label); save = new SaveStack(Offset_x_Save, Offset_y_Save); - this.add(save); + mouseL = new MyMouseListener(save); this.addMouseListener(mouseL); @@ -121,6 +121,7 @@ public class SolitaerGamePanel extends JPanel { deck.shuffelDeck(); for (int i = 0; i < STARTSTACK_SIZE; i++) { + start[i].clearStack(); int tmp = i; while (tmp != 0) { start[i].addCard(deck.getDeck().remove(0)); @@ -136,10 +137,12 @@ public class SolitaerGamePanel extends JPanel { for (int i = 0; i < ABLAGESTACK_SIZE; i++) { + ablage[i].clearStack(); this.add(ablage[i]); } - + geber.clearStack(); + waste.clearStack(); while (deck.getDeck().size() != 1) { geber.addCard(deck.getDeck().remove(0)); } @@ -150,6 +153,10 @@ public class SolitaerGamePanel extends JPanel { this.add(waste); this.add(geber); + + + save.clearStack(); + this.add(save);