Problem in ItemStateChange event

Hi all

When i try to use ItemStateChange event for JComboBox, it fires 2 times. For an example..

ResultSet rs = connection.doQuery("SELECT * FROM UserDetails WHERE Username = '"+ cmbUname.getSelectedItem().toString()+"'");

ResultSetMetaData metrs = rs.getMetaData();

int sCol = rs.findColumn("Description");

int eCol = metrs.getColumnCount();

String val;

for (int i=sCol+1;i<=eCol;i++)

{

//JOptionPane.showMessageDialog(null,cmbUname.getSelectedItem().toString());

JOptionPane.showMessageDialog(null,Integer.toString(i));

val = Integer.toString(rs.getInt(i));

if (val.equals("1"))

{

permision.setSelectedIndex(i);

}

}

above For loop run twice. I want to know is there any event in java Swing that i can use to solve above problem? (In C# there is an event called SelectedIndexChange)

Thankz

[910 byte] By [Sana_Boya] at [2007-11-27 7:46:30]
# 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.

Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html]How to Use Combo Boxes[/url] for examples of how to handle this.

If you want help in the future, then start responding to your other posting when people make an effort to help you:

http://forum.java.sun.com/thread.jspa?threadID=5184325

http://forum.java.sun.com/thread.jspa?threadID=5182487

http://forum.java.sun.com/thread.jspa?threadID=5184361

A simple thank-you shows that you actually took the time to read the suggestions that have been given.

camickra at 2007-7-12 19:27:24 > top of Java-index,Desktop,Core GUI APIs...
# 2
Thank you very much
Sana_Boya at 2007-7-12 19:27:24 > top of Java-index,Desktop,Core GUI APIs...