• 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

Real Time Applet Design

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need help with the design of my applet. It is a financial applet and it has several text boxes. I need to be able to gather information from the text boxes and display the results. The problem is that whenever a textbox value changes I want to update my total. Because there are so many text boxes it would be very difficult to maintain if I was to create an ActionListener class for each one of them, so I wanted a way to implement a Listener that would listen or wait for the text boxes to change and then automatically update itself. How do I implement such a thing and if you could provide some examples I would really appreciate it. Thank You in advance
 
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can reuse a single ActionListener for all your textfields. Than retrieve the info (using ((JTextField) actionEvent.getSource()).getText()) and than update the total value. (the tricky part would be the part when you really compute the total,as you would need to know the previous value ).

Another option is to make your computation on focus lost event (same mechanism as above).

--
./pope
[the_mindstorm]
[ January 21, 2005: Message edited by: Ali Pope ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic