aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes which listener to add Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "which listener to add" Watch "which listener to add" New topic
Author

which listener to add

kate damond
Ranch Hand

Joined: Apr 17, 2001
Posts: 77
Hi,
I have a JComboBox, which is editable : users can select from the predefined list, or type in their own figure. I don't really care whether the item changed because they typed a new figure, or because they selected a new item : I just want to respond to the fact that it changed. So, it seems to me, that it's like a JTextfield, where it's any change to the field's Document... I would do

but the comboBox doesn't appear to have a suitable Listener.
Any ideas ?
Cheers,
Kate
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Kate,
I haven't messed around much with ComboBoxes, but this seems like a great place to start. Check it out!
http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html#listeners
Manfred.
kate damond
Ranch Hand

Joined: Apr 17, 2001
Posts: 77
Well, it seems that the itemStateChanged event from ItemListener gets triggered as I need it. Alas, now I have to figure out how to distinguish between the two radio buttons, and two JComboBoxes that trigger this. If it was an ActionPerformed, it would be easy, but it's not, and I can't figure it out. I've tried but can't get at this property from the ItemEvent.
Any ideas ?
THanks,
Kate
kate damond
Ranch Hand

Joined: Apr 17, 2001
Posts: 77
Actually, I want to do something slightly better still. When any of my four event triggerers changes, I want to send 2 dates along with the change event. I can construct these 2 dates from the information available in the bean that the events are triggered from (actually from the 2 textfields that trigger events). So, all I need to know is, how to get at the ItemEvent as it is constucted, and alter something so that it sends this particular date.
Kate
Shishir Parikh
Greenhorn

Joined: Aug 09, 2001
Posts: 4
Hi Kate,
For knowing which of ur components has fired the ItemEvent, u may use getSource() of java.util.EventObject.
Cheers,
SHISH.
Originally posted by kate damond:
[B]Well, it seems that the itemStateChanged event from ItemListener gets triggered as I need it. Alas, now I have to figure out how to distinguish between the two radio buttons, and two JComboBoxes that trigger this. If it was an ActionPerformed, it would be easy, but it's not, and I can't figure it out. I've tried but can't get at this property from the ItemEvent.
Any ideas ?
THanks,
Kate[/B]

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: which listener to add