rendering JList according to selected item of JComboBox
hi friends
I have a JCombobox having 3 items and a JList. Now suppose some one selects the first item from the combobox say Item1 then according to that item the contents of list should be displayed and if he selects Item2 then according to that item the contents of list would be changed dynamically.
so anyone plz help me to solve my this problame i also paste the code which i thought to solve the above problame but i can't work.
String[] mah = {"mah1","mah2"};
Object[] mahObj = (Object[])mah;
String[] guj = {"guj1","guj2"};
Object[] gujObj = (Object[])guj;
private void sStateItemStateChanged(java.awt.event.ItemEvent evt) {
// TODO add your handling code here:
if(evt.getStateChange() == ItemEvent.SELECTED)
state = (String)evt.getItem();
if(state.equalsIgnoreCase("Item1")){
mList.setListData(mahObj);
else
if(state.equalsIgonreCase("Item2")){
mList.setListData(gujObj);
else
mList.setListData(defltObj);
}
}
In above code sState is my JComboBox and the mList is my JList
ishan

