Monday, December 14, 2009

How to Create Registration Forms in Java

Creating registration forms with Java by hand-coding them is a time-consuming and error-prone process. Fortunately, a number of free integrated development environments (IDEs) have intuitive interfaces and tools that make form creation easy.

Instructions

Things You'll Need:

  • NetBeans Integrated Development Environment from NetBeans.org
  • Java Development Kit from java.sun.org
  1. Step 1

    Download and install the free NetBeans IDE from NetBeans.org. (See Resources for other IDEs with similar form designers.)

  2. Step 2

    Open NetBeans and select "File>New Project." Select "Java" in the Categories window, and "Java Application" in the Projects window. Press "Next."

  3. Step 3

    Complete the New Java Application dialog box: enter "registerform" for "Project Name." Enter "c:\users\\Desktop\registerform" for the "Project Location." Leave the "Use Dedicated Folder..." check box unchecked, and also the "Create Main Class" box unchecked. Do check the "Set as Main Project" check box, then press "Finish."

  4. Step 4

    Expand the "registerform" node, which is in the Projects window, then its "Source Packages" node. Right-click on "" and select "New>Java package."

    In the "New Java Package" dialog box, enter "pkgRegform" for "Package Name," then click "Finish."

  5. Step 5

    Right-click the "pkgRegform" node in the "Projects" window and select "New>JFrame Fform." In the "New JFrame Form" dialog box, enter "frmRegform" for the "Class Name," then press "Finish."

  6. Step 6

    Click and drag a "Label" control from the "Palette" window onto the form, near the form's upper left corner. Right-click on the label control and select "Properties," then locate the "text" property. Type "first name" to replace the default text for that control. Click the "Close" button on the "Properties" dialog box.

  7. Step 7

    Drag a "Text Field" onto the form from the Palette window. Position the text field to the right of the label control. Using the Properties dialog box, delete the default text from the text field.

  8. Step 8

    Repeat steps 6 and 7 to create a label and associated text box for the "Last Name" field. Position the new controls directly under the first two. Under the controls for the last name, add a label and text box control for an email address.

  9. Step 9

    Add a button under the email label. Using the Properties window, change its "Text" property to read "Submit."

  10. Step 10

    Resize the form by dragging its lower right corner. Position that corner so that the white space between the controls and the form's borders is visually agreeable.

  11. Step 11

    Preview your form by right-clicking on it and selecting "Preview Design." In the context menu that appears, choose the form type (i.e. "Metal," "Nimbus," "Windows Classic") that matches your project's design specifications.

  12. Step 12

    Double-click the button to enter the code window. Enter the Java program code needed to route the data that your form has gathered to the destination indicated in your project's specifications.

No comments:

Post a Comment