Application developed with Visual J++, Part 2.

 

2nd Step, Rename the Form1.java created abd Add Controls to it

The Form1.java will be renamed to MainForm.java

  1. Rename ...
    1. In the Project Explorer, select the item - Form1.java.
      On the File menu, click Rename.
      In the Project Explorer, edit the item name - MainForm.java.
    2. Modify the Codes created ...- Examine these changes:
      -
      The text Code created by the wizard is black.
      -
      The new text Code to be add is red.
      -
      The text Code to be remove is navy and Strikethrough effects.
      import com.ms.wfc.app.*;
      import com.ms.wfc.core.*;
      import com.ms.wfc.ui.*;
      import com.ms.wfc.html.*;

      /**
      * This class can take a variable number of parameters on the command
      * line. Program execution begins with the main() method. The class
      * constructor is not invoked unless an object of type 'Form1' is
      * created in the main() method.
      */

      public class Form1 extends Form
      {
      public Form1()

      public class MainForm extends Form
      {
      public MainForm()

      {
      // Required for Visual J++ Form Designer support
      initForm();

      // TODO: Add any constructor code after initForm call
      }

      /**
      * Form1 overrides dispose so it can clean up the
      * MainForm overrides dispose so it can clean up the
      * component list.
      */
      public void dispose()
      {
      super.dispose();
      components.dispose();
      }

      /**
      * NOTE: The following code is required by the Visual J++ form
      * designer. It can be modified using the form editor. Do not
      * modify it using the code editor.
      */
      Container components = new Container();

      private void initForm()
      {
      this.setSize (new Point(300,300));
      this.setText ("Form1");
      this.setText ("MainForm");
      }

      /**
      * The main entry point for the application.
      *
      * @param args Array of parameters passed to the application
      * via the command line.
      */
      public static void main(String args[])
      {
      Application.run(new Form1());
      Application.run(new MainForm());
      }
      }


    3. On the Project menu, click TestVJ Properties...
      The TestVJ Properties dialog box appears, Select the Launch tab, choose the file MainForm to use when your project is run inside Visual J++ and then click Ok
  2. The MainForm.java, Form properties
    Items Old values (Form1.java) New values (MainForm.java)
    borderStyle:
    menu:
    Sze:
    StartPosition:
    Text:
    Sizable
    none
    300, 300
    Windows default
    Form1
    Sizable Toolwindow
    mainmenu1
    644, 420
    Center Screen
    Main ...


  3. The MainForm.java design
     Main ...
     
       
       
     
     
      Learn how to write a Microsoft Visual J++ application ...
    .
     
        11:22:57 AM


  4. Add New Folder and file..
    On the Project menu, click New Folder, the Add Package/Folder dialog box appears, type Pic folder name, click Ok
    From the ...\VJ App\res folder copy the followihg files:
    1. The ingraphic1.gif  file  to the folder C:\TestVJ\Pic .
    2. The  LearnJava.ico file to the folder C:\TestVJ\Pic .

       
  5. Add the following controls, from the Toolbox :
    One MainMenu, one PictureBox, two labels and one Timer .

    Note:
    Toolbox
    - Displays design-time controls, ActiveX controls, applets, HTML scraps, objects, and text based on the designer or editor you are using to build a project.

    1. Add the MainMenu  control -mainMenu1, Properties:
      To add a menu, you drag the MainMenu control from the Toolbox onto the form. Once the menu is enabled on the form, the menu designer lets you add submenus and menu items by simply typing them in. Each menu item has an event handler that can be hooked up in the coding phase of development.
      name: MainMenu1

      In the default locations TestBox type the name of the menu tems ...
      The Properties values of the MenuItems:

      Name Type Text
      1- Infomenu
      2- Bookmenu
      3- seperator1
      4- Aboutmenu
      5- seperator2
      4- Exitmenu
      MenuItem
      MenuItem
      MenuItem
      MenuItem
      MenuItem
      MenuItem
      Info Menu
      Book
      -
      About
      -
      Exit


      The menu designs:

       


    2. Add the PictureBox control - PictureBox1,  Properties:
      A PictureBox control can display a graphic from a bitmap, icon, or metafile, as well as enhanced metafile, JPEG, or GIF files. It clips the graphic if the control isn't large enough to display the entire image.
      image:
      name:
      Location:
      Size:
      none
      PictureBox1
      128, 64
      378, 199

      Note
      :The PictureBox1
      displays the file ingraphic1.gif - (stored in the folder C:\TestVJ\ Pic).

    3. Add the Label control - Teachlabel,  Properties:
      A Label object is a component for placing text in a container. A label displays a single line of read-only text. The text can be changed by the application, but a user cannot edit it directly.
      name:
      Font:
      text:
      textAlign:
      Teachlabel
      Times New roman, Bold Italic, size = 12
      Learn how to write a Microsoft Visual J++ Application
      Center


    4. Add the Label control - lbtime,  Properties:
      A Label object is a component for placing text in a container. A label displays a single line of read-only text. The text can be changed by the application, but a user cannot edit it directly.
      name:
      text:
      textAlign:
      lbtime

      Center


    5. Add the Timer control - Timer1,  Properties:
      The Timer control is used to trigger an event at user-defined intervals. Use the control's Timer event to perform a polling operation or to display a splash screen for a specified amount of time.
      enabled:
      Interval:
      Name:
      True
      100
      Timer1


  6. The MainForm.java Codes ... (Click here)

    Note:
    Adding an event handlers
    You can use the Forms Designer to create event handlers. An event handler is a routine in your code that determines which actions to perform when an event occurs, such as the user's clicking a button.
  7. Click the control (such as a button control) or form you want an event handler created for.
  8. In the Properties window, click the events view button (indicated by a thunderbolt symbol).
  9. In the list of available events, click an event (for example, click).
  10. In the box to the right of the event name, type the name of the handler (for example, MyButton_click), and press ENTER.

Previous
  Home
2
 
Next