[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

JComboBox changed event

I thought that the ActionPerformed() would fire an event if I changed the selection in a combo box, however fires even when the component is loaded.  What event do I use to fire only when  user makes a selection?

Thanks,
David
0
lomidien
Asked:
lomidien
  • 5
1 Solution
 
zzynxSoftware engineerCommented:
You should use actionPerformed()
0
 
zzynxSoftware engineerCommented:
>> however fires even when the component is loaded
I use a flag to skip the changes when loading
0
 
zzynxSoftware engineerCommented:
boolean skipChanges = false;


skipChanges = true;
// fill up the combobox and make initial selections
skipChanges = false;


public void actionPerformed(ActionEvent evt) {
   if (skipChanges) return;

   // do what you want
}
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
lomidienAuthor Commented:
Perfect, thanks a bunch.

David
0
 
zzynxSoftware engineerCommented:
>> however fires even when the component is loaded.
Rather logical after a second thought, since loading the component = selecting the first item in it
0
 
zzynxSoftware engineerCommented:
You're welcome
Thanks for accepting :°)
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now