As with any Java™ application, you must begin by importing the necessary classes and defining the program's classes.
- Create a new Java source file called calculateAge.java.
- Any program that calls methods from the API must import the following classes:
- You must place these lines before any class or interface definitions.
- Set up the rest of your application. This generally includes defining any classes and methods for your application as well as declaring and initializing any variables you may need. The following code sets up the Calculate Age application:
- Create the public class CalculateAge and the main method for the class.
public class CalculateAge
- Declare a FormNodeP object called theForm to represent the form.
private static FormNodeP theForm;
- Create the program's main method.
public static void main(String argv )
- Declare the program's variables.
- The program's main method essentially consists of a series of calls to other methods. The Form Library methods are called from the definition of these methods.
birthYear = getBirthYear();
birthMonth = getBirthMonth();
birthDay = getBirthDay();
- Free the memory in which the form was stored. For more information see Closing a Form .
- Finally, perform exception handling.
catch (Exception ex)
/* Additional code removed */
Parent topic: Developing an application in Java