| Author |
JComboBox
|
Rick Gentry
Ranch Hand
Joined: Dec 14, 2002
Posts: 63
|
|
|
I've got a JComboBox and I want to recieve an event when a new item is selected. I've tried an ActionListener and an ItemListener. Neither one wants to work for me. Any help?
|
 |
Sonny Gill
Ranch Hand
Joined: Feb 02, 2002
Posts: 1211
|
|
I suggest that you post some relevant code, and somebody may be able to help. cheers
|
 |
Rick Gentry
Ranch Hand
Joined: Dec 14, 2002
Posts: 63
|
|
Let's see here relevant code.....I don't have any, that's what I'm asking for help with. All I know is it's going to go something like this. That's about as relevant as I can get without an answer.
|
 |
Don Kiddick
Ranch Hand
Joined: Dec 12, 2002
Posts: 580
|
|
You need an ItemListener. D.
|
 |
Rick Gentry
Ranch Hand
Joined: Dec 14, 2002
Posts: 63
|
|
Yeah, I had an ItemListener. Changing the selected item activates itemStateChanged but e.getSource() doesn't return the JComboBox.
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15229
|
|
|
Moving to Swing...
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15229
|
|
Originally posted by Rick Gentry: Yeah, I had an ItemListener. Changing the selected item activates itemStateChanged but e.getSource() doesn't return the JComboBox.
Yes it does. But you have to cast it.
|
 |
Rick Gentry
Ranch Hand
Joined: Dec 14, 2002
Posts: 63
|
|
|
I got it work, I was declaring the box outside the function but finished declaring it inside. So the box was null when it got to the ItemEvent. So in short I made a stupid mistake that I've made before and I'm sure I'll make again. Thanks for the help though.
|
 |
 |
|
|
subject: JComboBox
|
|
|