From b16c5e74ad3f4673d76c414c9bddd6ac3e2d9d03 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 30 Jan 2022 16:23:55 +0100 Subject: [PATCH] Add render for AblageStack --- src/main/java/solitaer/AblageStack.java | 29 +++++++++++++++++++ src/main/java/solitaer/SolitaerGamePanel.java | 15 ++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/main/java/solitaer/AblageStack.java b/src/main/java/solitaer/AblageStack.java index 0e436b6..56439a0 100644 --- a/src/main/java/solitaer/AblageStack.java +++ b/src/main/java/solitaer/AblageStack.java @@ -1,5 +1,9 @@ package solitaer; +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics; + public class AblageStack extends BaseStack { private static final long serialVersionUID = 1L; @@ -30,5 +34,30 @@ public class AblageStack extends BaseStack { } } + + @Override + protected void paintComponent(Graphics g) { + // TODO Auto-generated method stub + super.paintComponent(g); + if (stackIsEmpty()) { + g.setColor(Color.gray); + g.fillRect(0, 0, this.getWidth(), IMAGE_HIGHT); + + g.setColor(Color.black); + g.drawRect(0, 0, this.getWidth()-1, IMAGE_HIGHT-1); + + if (this.sym == Symbol.Herz || this.sym == Symbol.Karo) + g.setColor(Color.red); + else + g.setColor(Color.black); + + int fontSize = 20; + Font f = new Font(Font.MONOSPACED, Font.BOLD, fontSize); + g.setFont(f); + + String text = this.sym.toString(); + g.drawString(text, 5, this.IMAGE_HIGHT/2); + } + } } diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index d94b99c..a7a56f5 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -25,7 +25,7 @@ public class SolitaerGamePanel extends JPanel { - StartStack a = new StartStack(25,25); + StartStack a = new StartStack(25,125); a.addCard(deck.getDeck().get(0)); @@ -46,13 +46,13 @@ public class SolitaerGamePanel extends JPanel { this.add(a); - StartStack b = new StartStack(200,25); + StartStack b = new StartStack(200,125); deck.getDeck().get(32).setFaceUp(true); b.addCard((deck.getDeck().get(32))); this.add(b); - StartStack c = new StartStack(375,25); + StartStack c = new StartStack(375,125); deck.getDeck().get(33).setFaceUp(true); c.addCard((deck.getDeck().get(33))); @@ -62,6 +62,15 @@ public class SolitaerGamePanel extends JPanel { this.add(save); + AblageStack a1 = new AblageStack(200, 10, Symbol.Herz); + this.add(a1); + AblageStack a2 = new AblageStack(275, 10, Symbol.Kreuz); + this.add(a2); + AblageStack a3 = new AblageStack(350, 10, Symbol.Karo); + this.add(a3); + AblageStack a4 = new AblageStack(425, 10, Symbol.Pik); + this.add(a4); + }