Browse Source

Add Offset for startStack

feature_solitaer_StartStack
Alexander Hartung 3 years ago
parent
commit
51d1e8c7ab
  1. 3
      src/main/java/solitaer/Card.java
  2. 9
      src/main/java/solitaer/StartStack.java

3
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);
}
}

9
src/main/java/solitaer/StartStack.java

@ -13,20 +13,25 @@ public class StartStack extends JPanel {
private Image im;
private ArrayList<Card> stack = new ArrayList<Card>();
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-- ) {

Loading…
Cancel
Save