Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ItemStateListener & Interaction between two choicegroups

 
Janne Pysays
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've done a raw sketch to initiate a choicegroup depending on the choice in an other choicegroup. The problem is: how do I prevent multiple choicegroup initiations (this model creates a new object with every selection). Note that the real issue here is that the array should change depending on the first selection (it already does); if I choose the first option the options in the second group give 1 to 3, the second option would give one and two. The current approach is most likely a flawed one. Should the initiated group be somehow destroyed so that if an another selection is made, this new selection would replace the old object?

public Item getCG(int cg_choice){
String[] firstarray = new String[]{"one", "two", "three"};
String[] secondarray = new String[]{"one", "two"};
ChoiceGroup cgTest = null;

switch(cg_choice){
case 0:
cgTest = new ChoiceGroup("1 - 3", Choice.POPUP, firstarray, null);
break;


case 1:
cgTest = new ChoiceGroup("1 - 2:", Choice.POPUP, secondarray, null);
break;



}

return cgTest;

}


public void itemStateChanged(Item item) {
if(item == cgTest2){
int cg_index = cgTest2.getSelectedIndex();

switch(cg_index){
case 0:

frmTest.append(getCG(0));
break;

case 1:

frmTest.append(getCG(1));
break;

default:
break;
}
}
}

[ June 05, 2004: Message edited by: Janne Pysays ]
[ June 05, 2004: Message edited by: Janne Pysays ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic