Black jack program using gui
<p>hello i am writing a black jack program and i want to be able to display the cards that i made.. i imported images of each card and and assigned each to a specific suit and card number using cases then i made a deck which is a stack and added each card into the that. i made a method that shuffles the card deck and pops the first one. I want to display each card each time a button is pressed, how do i do that?</p>

<p>my code...</p>

<pre><code>public class CardList {

    private Stack&lt;Cards&gt; list;

    public CardList(){
        list = new Stack&lt;Cards&gt;();


        for(Cards.CardSuit suit:Cards.CardSuit.values()){
            for(int i=1; i&lt;=13; i++){
                list.push(new Cards(suit, i));
            }
        }
    }

    public Cards getCard()
    {
        shuffle();
        return list.pop();

    }

    public void shuffle(){
        Collections.shuffle(list);
    }
}


public class Cards 
{

    public enum CardSuit{DIAMOND, SPADE, CLUB, HEART};

    private BufferedImage image;
    int num; 
    CardSuit s;


    public Cards(CardSuit suit, int number){
        num = number;
        s = suit;
        image = createCard(suit, number);
    }   



    public Cards() {
        // TODO Auto-generated constructor stub
    }



    public BufferedImage createCard(CardSuit s , int num)
    {
        switch (s)
        {
            case DIAMOND :
                switch (num)
                {   
                    case 1:
                        try {                
                              image = ImageIO.read(new File("ad.gif"));
                           } catch (IOException ex) {
                                // handle exception...
                           }
                    case 2: 
                        try {                
                              image = ImageIO.read(new File("2d.gif"));
                           } catch (IOException ex) {
                                // handle exception...
                           }
                    case 3: 
                        try {                
                              image = ImageIO.read(new File("3d.gif"));
                           } catch (IOException ex) {
                                // handle exception...
                           }
                    case 4:
                        try {                
                              image = ImageIO.read(new File("4d.gif"));
                           } catch (IOException ex) {
                                // handle exception...
                           }
                    case 5:
                        try {                
                              image = ImageIO.read(new File("5d.gif"));
                           } catch (IOException ex) {
                                // handle exception...
                           }
                    case 6:
                        try {                
                              image = ImageIO.read(new File("6d.gif"));
                           } catch (IOException ex) {
                                // handle exception...
                           }
                    case 7:
                        try {                
                              image = ImageIO.read(new File("7d.GIF"));
                           } catch (IOException ex) {
                                // handle exception...
                           }
                    case 8:
                        try {                
                              image = ImageIO.read(new File("8d.gif"));
                           } catch (IOException ex) {
                                // handle exception...
                           }
                    case 9:
                        try {                
                              image = ImageIO.read(new File("9d.gif"));
                           } catch (IOException ex) {
                                // handle exception...
                           }
                    case 10:
                        try {                
                              image = ImageIO.read(new File("td.gif"));
                           } catch (IOException ex) {
                                // handle exception...
                           }
                    case 11:
                        try {                
                              image = ImageIO.read(new File("jd.gif"));
                           } catch (IOException ex) {
                                // handle exception...
                           }
                    case 12:
                        try {                
                              image = ImageIO.read(new File("kd.gif"));
                           } catch (IOException ex) {
                                // handle exception...
                           }
                    case 13:
                        try {                
                              image = ImageIO.read(new File("qd.gif"));
                           } catch (IOException ex) {
                                // handle exception...
                           }
                }
            break;  
            case SPADE:
                switch (num)
                {
                case 1:
                    try {                
                          image = ImageIO.read(new File("as.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 2: 
                    try {                
                          image = ImageIO.read(new File("2s.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 3: 
                    try {                
                          image = ImageIO.read(new File("3s.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 4:
                    try {                
                          image = ImageIO.read(new File("4s.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 5:
                    try {                
                          image = ImageIO.read(new File("5s.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 6:
                    try {                
                          image = ImageIO.read(new File("6s.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 7:
                    try {                
                          image = ImageIO.read(new File("7s.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 8:
                    try {                
                          image = ImageIO.read(new File("8s.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 9:
                    try {                
                          image = ImageIO.read(new File("9s.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 10:
                    try {                
                          image = ImageIO.read(new File("ts.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 11:
                    try {                
                          image = ImageIO.read(new File("jc.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 12:
                    try {                
                          image = ImageIO.read(new File("ks.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 13:
                    try {                
                          image = ImageIO.read(new File("qs.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }

                }
            break;  
            case CLUB:
                switch (num)
                {
                case 1:
                    try {                
                          image = ImageIO.read(new File("ac.gif"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 2: 
                    try {                
                          image = ImageIO.read(new File("2c.gif"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 3: 
                    try {                
                          image = ImageIO.read(new File("3c.gif"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 4:
                    try {                
                          image = ImageIO.read(new File("4c.gif"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 5:
                    try {                
                          image = ImageIO.read(new File("5c.gif"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 6:
                    try {                
                          image = ImageIO.read(new File("6c.gif"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 7:
                    try {                
                          image = ImageIO.read(new File("7c.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 8:
                    try {                
                          image = ImageIO.read(new File("8c.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 9:
                    try {                
                          image = ImageIO.read(new File("9c.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 10:
                    try {                
                          image = ImageIO.read(new File("tc.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 11:
                    try {                
                          image = ImageIO.read(new File("jc.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 12:
                    try {                
                          image = ImageIO.read(new File("kc.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 13:
                    try {                
                          image = ImageIO.read(new File("qc.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                }
            break;  
            case HEART:
                switch (num)
                {
                case 1:
                    try {                
                          image = ImageIO.read(new File("ah.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 2: 
                    try {                
                          image = ImageIO.read(new File("2h.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 3: 
                    try {                
                          image = ImageIO.read(new File("3h.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 4:
                    try {                
                          image = ImageIO.read(new File("4h.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 5:
                    try {                
                          image = ImageIO.read(new File("5h.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 6:
                    try {                
                          image = ImageIO.read(new File("6h.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 7:
                    try {                
                          image = ImageIO.read(new File("7h.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 8:
                    try {                
                          image = ImageIO.read(new File("8h.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 9:
                    try {                
                          image = ImageIO.read(new File("9h.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 10:
                    try {                
                          image = ImageIO.read(new File("th.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 11:
                    try {                
                          image = ImageIO.read(new File("jh.GIF"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 12:
                    try {                
                          image = ImageIO.read(new File("kh.gif"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                case 13:
                    try {                
                          image = ImageIO.read(new File("qh.gif"));
                       } catch (IOException ex) {
                            // handle exception...
                       }
                }   
        }
        return image;
    }

    public int carNum()
    {
        return num;
    }
     public void paintComponent(Graphics g) {
            g.drawImage(image, 0, 0, null); // see javadoc for more info on the parameters


     }
     public String toString()
        {
            return  "" +image;

        }
</code></pre>
