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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "dynamic applet" Watch "dynamic applet" New topic
Author

dynamic applet

Alex Kravets
Ranch Hand

Joined: Jan 24, 2001
Posts: 476
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
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8843
    
    7

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
jQuery in Action, 2nd edition
 
subject: dynamic applet
 
Similar Threads
forbean's getmethod never called
how to align components in GridBagLayout in JAVA swing
Change values in the header of a table
jtips
Jcombobox