From 6c2aaeb146d57f157f6b27933c27ca66c487ebfe Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Fri, 4 Feb 2022 22:08:17 +0100 Subject: [PATCH] Fix MouseListener --- src/main/java/solitaer/MyMouseListener.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/solitaer/MyMouseListener.java b/src/main/java/solitaer/MyMouseListener.java index 70aec81..d222ac6 100644 --- a/src/main/java/solitaer/MyMouseListener.java +++ b/src/main/java/solitaer/MyMouseListener.java @@ -29,14 +29,7 @@ public class MyMouseListener implements MouseInputListener { // TODO Auto-generated method stub System.out.println("DOWN"); Component com = SwingUtilities.getDeepestComponentAt(e.getComponent(), e.getX(), e.getY()); - -// // Leeres StartFeld -// if (com instanceof StartStack) { -// System.out.println("Leer Start"); -// -// } -// // Karte, die in einem StartStack liegt -// else + if ((com instanceof Card && com.getParent() instanceof StartStack) || (com instanceof StartStack && ((StartStack) com).stackIsEmpty())) { @@ -152,6 +145,12 @@ public class MyMouseListener implements MouseInputListener { } else { clearSaveStack(selectedStack); } + //Clear SaveStack click on SolitaerGamePanel + }else if(com instanceof SolitaerGamePanel || + com.getParent() instanceof SolitaerGamePanel && com instanceof StartStack ){ + if(saveStack.stackIsEmpty() == false) { + clearSaveStack(selectedStack); + } } }