Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Java Swing bug or error in program??(Actionperformed not triggered for JComboBox)
Java Swing bug or error in program?? [message #648076] Tue, 11 January 2011 06:12
Niranjani S is currently offline Niranjani SFriend
Messages: 3
Registered: August 2010
Junior Member
I have an ActionListener attached to a JComboBox(uneditable). Once an item from the JComboBox is selected, I have to make the next button in the frame visible.

The skeleton of the code looks like this:

public void actionPerformed(ActionEvent evt)
{
if(evt.getSource()==jComboBox){
if(jComboBox.getSelectedIndex()==-1)
//Display an alert message

else{
nextButton.setVisible(true);
//Do other actions
}
}
}

It is found that actionPerformed is called only when the second, third, fourth (and so on) items are selected. But actionPerformed is not called when the first item is selected the very first time. But if the first item is selected after selecting other items actioPerformed gets called and the code works fine.

This error appears on some systems and doesn't on other systems. Any help in this regard would be appreciated.

Thanks in Advance!!
Previous Topic:Getting Java (DynWeb) Build Path to work correctly
Next Topic:How can I extend JDT's annotation validation mechanism?
Goto Forum:
  


Current Time: Fri Dec 19 08:57:33 GMT 2014

Powered by FUDForum. Page generated in 0.02335 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software