• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

which listener to add

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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]


 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic