I have an ArrayList of 52 card ImageIcons. I then use Collections.shuffle to randomize the cards. I want to put this ArrayList into individual JLabels to display in the JPanel.
I cant seem to figure out how to put the ArrayList into JLabels. Is this possible or is there a better method for GUI instead of JFrame like paint() method?
I will post the snippet of code below.
I have tried putting cardArray in the JLabel but that doesnt work. I have scoured this site and others trying to find any answer but to no avail. Any help or ideas would be appreciated.Code:ImageIcon[] cards = new ImageIcon[53]; ArrayList<ImageIcon> cardArray = new ArrayList<ImageIcon>(); for(int b=0; b<cards.length; b++) { cards[b]=new ImageIcon("C:/NetBeansProjects/BiddingTool/src/biddingtool/cards/"+b+".gif"); cardArray.add(cards[b]); } Collections.shuffle(cardArray); List northlist = cardArray.subList(0,13); frame2.add(northcards, BorderLayout.NORTH); for (int i=0; i<north.length; i++) { northcards.add(new JLabel()); }




Reply With Quote
