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 01:12
Niranjani S is currently offline Niranjani S
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: Wed Aug 20 00:53:59 EDT 2014

Powered by FUDForum. Page generated in 0.01924 seconds