Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OnChange for JComboBox

Status
Not open for further replies.

ASarine

Programmer
Jun 18, 2002
1
BE
I try to act an "onchange" event on a JCombobox but the only way I Found is with the action event list , but it doesn't work anyone can help me please....
Best regards
 
Try adding a ActionListener and implementing the actionPerformed method of that interface.

Here is some example code:

public void actionPerformed( ActionEvent event )
{
Object source = event.getSource();

if( source == comboBox )
{
// insert code here
}
}

-gc "I don't look busy because I did it right the first time."
 
combo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
yourMethodHere();
}
});
 
ghorr :

In the future please do not drag up threads that are over 3 years old just to provide an answer !

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
... especially when the OP hasn't marked the thread for notification.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
And I'd add a ChangeListener, it's stateChanged method would work for me.

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top