Hi guys, I wrote an applet that we use in our company which is dynamic. Dynamic meaning that when applet is launched it reads a file on a server that describles how components of an applet should look and where they should be positioned. A typical file might looks like this:
This will create an applet with a JComboBox and two components of type DecimalField below it. What I need is to create a component that would display total values entered into two DecimalFields. So, if value for sz2_1 is 5.5 and value for sz2_2 is 4.5, the values for total of these two fields would be displayed in total fields (TotalField) = 10.00. The problem is that this TotalField should be a separate component that extends JTextField and displays total values of two fields as values are being entered into the fields. I could define TotalField as:
I know how I am going to implement TotalField, but how can read values that are in dynamic applet's fields as they are being entered? thanks, Alex
All right brain, you don't like me and I don't like you, but let's just do this one thing so I can get back to killing you with beer.<br /> <br />- Homer Simpson
Make some class that has access to all the entry fields implement java.awt.event.FocusListener. When you create an entry field, add that class to their listeners with entryField.addFocusListener(). When the user tab's out of that field, the method focusLost() is called on the class implementing FocusListener. In that method do the calculation and set the value in the total field.