From f95187e009424b4fecb31f55a43cc6a72f17d988 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 30 Jan 2022 17:58:22 +0100 Subject: [PATCH] Add render for GeberStack --- src/main/java/solitaer/GeberStack.java | 19 +++++++++++++++++++ src/main/java/solitaer/SolitaerGamePanel.java | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/src/main/java/solitaer/GeberStack.java b/src/main/java/solitaer/GeberStack.java index b3c6e58..9e10e10 100644 --- a/src/main/java/solitaer/GeberStack.java +++ b/src/main/java/solitaer/GeberStack.java @@ -1,5 +1,8 @@ package solitaer; +import java.awt.Color; +import java.awt.Graphics; + public class GeberStack extends BaseStack { private static final long serialVersionUID = 1L; @@ -21,5 +24,21 @@ public class GeberStack extends BaseStack { // TODO Auto-generated method stub return false; } + + @Override + protected void paintComponent(Graphics g) { + // TODO Auto-generated method stub + super.paintComponent(g); + if (stackIsEmpty()) { + g.setColor(Color.pink); + g.fillRect(0, 0, this.getWidth(), IMAGE_HIGHT); + + g.setColor(Color.black); + g.drawRect(0, 0, this.getWidth() - 1, IMAGE_HIGHT - 1); + + String text = "Start\nAgain"; + 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 4c16f06..834e22a 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -77,6 +77,13 @@ public class SolitaerGamePanel extends JPanel { this.add(a4); + WasteStack w = new WasteStack(85, 10); + GeberStack g = new GeberStack(10, 10, w); + + this.add(w); + this.add(g); + + }