Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ComboBox - ItemStateChanged Event - is being fired twice

843806Apr 1 2009 — edited Apr 1 2009
I'm getting 2 Message Dialogs when I select a different item on a JComboBox. I've debugged the application and found that the event was being fired twice even when I've changed the item once.

Here's the sample code (Using Netbeans IDE 6.5.1 to design and code)

{color:#993300}private void jComboBox1ItemStateChanged(java.awt.event.ItemEvent evt)
{
// TODO add your handling code here:
JOptionPane.showMessageDialog(null, "Hi", "Hello", JOptionPane.ERROR_MESSAGE);
}
{color}
Is this expected? In case it is, can someone help me with the correct code, that will display the message dialog only once.+
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 29 2009
Added on Apr 1 2009
3 comments
471 views