File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "dynamic applet" Watch "dynamic applet" New topic

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?

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

Joined: Oct 29, 2001
Posts: 9189

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.

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: dynamic applet
It's not a secret anymore!