wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Real Time Applet Design Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Real Time Applet Design" Watch "Real Time Applet Design" New topic
Author

Real Time Applet Design

Firdos Ali
Greenhorn

Joined: Jan 21, 2005
Posts: 1
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
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
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 ]

blog - InfoQ.com
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Real Time Applet Design
 
Similar Threads
How to display string array value in jsp for html:text box
How to take dynamic values of textboxes to Action class
URGENT - Performance issue with Matrix Applet
Applet Repaint
Applets - web application