Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dynamic applet

 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Joe Ess
Bartender
Pie
Posts: 9265
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic