This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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
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 ]