Java 2d array with Icon names -
do can fill 2d array icon file names this? im getting error says
type mismatch: cannot convert string icon
so question is, imposible fill 2d array icon file names, or made small error here? keep getting error on array.
public icon cards[][] = {{"diamonds 2.png", "diamonds 3.png", "diamonds 4.png", "diamonds 5.png", "diamonds 6.png", "diamonds 7.png", "diamonds 8.png", "diamonds 9.png", "diamonds 10.png", "diamonds jack.png", "diamonds queen.png", "diamonds king.png", "diamonds ace.png"}, {"hearts 2.png", "hearts 3.png", "hearts 4.png", "hearts 5.png", "hearts 6.png", "hearts 7.png", "hearts 8.png", "hearts 9.png", "hearts 10.png", "hearts jack.png", "hearts queen.png", "hearts king.png", "hearts ace.png"}, {"clubs 2.png", "clubs 3.png", "clubs 4.png", "clubs 5.png", "clubs 6.png", "clubs 7.png", "clubs 8.png", "clubs 9.png", "clubs 10.png", "clubs jack.png", "clubs queen.png", "clubs king.png", "clubs ace.png"}, {"spades 2.png", "spades 3.png", "spades 4.png", "spades 5.png", "spades 6.png", "spades 7.png", "spades 8.png", "spades 9.png", "spades 10.png", "spades jack.png", "spades queen.png", "spades king.png", "spades ace.png"}};
i have changed array name check, maybe when im using it, cause problem, no, same error on array.
as others have said, creating 2d array of strings.
so, change 2d array definition to:
public string[][] cards = //...
then, iterate on 2d array, , load icon each string:
icon[][] icons = new icon[cards.length][]; for(int i=0;i<cards.length;i++){ icons[i] = new icon[cards[i].length]; for(int j=0;j<cards[i].length;i++){ icons[i][j] = //load icon cards[i][j]; } }
and use icons
2d array set icons on labels mentioned in comments.
Comments
Post a Comment