For Programmers: Free Programming Magazines  


Home > Archive > Java Help > March 2008 > Show image from comboBox selected









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Show image from comboBox selected
taingaukwai@gmail.com

2008-03-06, 4:38 am

I want to show a card image in label of a panel. I try to create
three array:
public String[][] CardStrings
= {{ "as", "2s", "3s", "4s", "5s", "6s", "7s", "8s", "9s",
"ts", "js", "qs", "ks" },
{ "ah", "2h", "3h", "4h", "5h", "6h", "7h", "8h", "9h",
"th", "jh", "qh", "kh" },
{ "ac", "2c", "3c", "4c", "5c", "6c", "7c", "8c", "9c",
"tc", "jc", "qc", "kc" },
{ "ad", "2d", "3d", "4d", "5d", "6d", "7d", "8d", "9d",
"td", "jd", "qd", "kd" }};
public String [] strSuit = {"Spades", "Hearts", "Diamonds", "Clubs"};
public String [] strNum = {"Ace", "2", "3", "4", "5", "6", "7", "8",
"9", "10", "Jack", "Queen", "King"};

Then, one JcomboBox1 load strSuit[] & another one JcomboBox2 load
strNum[], it record its index and so I use Actionlistener to hear
e.getSource() any change. For example, I choose (Hearts, 2) that may
comboBox1.getSelectedIndex(1) & comboBox2.getSelctedIndex(1). The
question is how to combine 2 index to point string "2h" that load my
card image from img folder




Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com