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

[1121 byte] By [ishana] at [2007-11-27 2:34:43]
# 1

Don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags[/url] so the posted code retains its original formatting.

This posting has a similiar example to what your want except selecting an item in the combo box updates a second combo box. The concept would be the same for updating a JList:

http://forum.java.sun.com/thread.jspa?forumID=57&threadID=688505

camickra at 2007-7-12 2:52:22 > top of Java-index,Desktop,Core GUI APIs...