Creating and Building a WFC Application

   

Thanks for using this pre-release version of Visual J++.

This procedure shows you how to create a Windows application with the WFC Designer and controls. The application created populates a list box with a string whenever the applicationÆs button is clicked. Once youÆve compiled the application cleanly, you will run it from the development environment.

Tip   Before beginning the following procedure, close all open projects by clicking Close All from the File menu.

To open the WFC Designer when creating a Windows application with WFC controls

  1. On the File menu, click New Project and the New Project dialog box appears.

  2. On the New tab, expand the Visual J++ Projects folder and then the Applications folder.

    Note   Expand items in the environment by either double-clicking a folder or single-clicking a ô+ö sign to the left of a folder.

  3. Click the Windows Application icon.

  4. In the Name text box, enter a name for your applicationÆs project.

  5. In the Location text box, enter the path for the directory where you want to save your project

    ûorû

    Click the Browse button to navigate to the folder where you want to save your project.

  6. Click Open.

    A collapsed view of your application project appears in Project Explorer.

  7. In Project Explorer, click the ô+ö sign next to your projectÆs name to expand the projectÆs node.

  8. Double-click the applicationÆs Form1.java file.

    The WFC Designer appears and is ready to accept WFC controls from the Toolbox.

To add WFC controls to the WFC Designer

  1. On the Toolbox, click the WFC button to display the WFC controls available for placement on your applicationÆs form.

  2. In the Toolbox, select the Button control.

  3. Drag the Button to the position on the form where you want it to appear, and release the mouse button.

    Note   Once the control has been placed on the form, you may move it to a different location when the arrow changes to a move cursor over the control. You may adjust its size with the controlÆs sizing handles.

  4. With the cursor over the Button control, click the right mouse to display the shortcut menu.

  5. From the shortcut menu, select Properties and the Property Browser appears.

  6. In the Property Browser, find the Text property and change its value from ôbutton 1ö to ôAdd Itemö.

    Now the button on the form displays the new value.

  7. In the Toolbox, select the ListBox control and drag it to a position just below the Add Item button.

    Since youÆll be displaying text in the ListBox control, adjust its size to hold several lines of text.

To add a button click event handler

  1. Double click the Button control.

    A Text editor window opens to an empty event handler for the buttonÆs click event.

  2. Between the braces of the button1_Click() event handler, add the following code:

    listBox1.addItem(ôThis is a new string.ö);

    When youÆve finished this step, the event handler look like this:

   private void button1_Click(Object sender, Event e)
{

listBox1.addItem(ôThis is a new string.ö);

   } 

To build a WFC application

To see the results of the code youÆve added to the Windows Application template, you will need to run the application. See Running a WFC Application from the Environment for details to run the application from within the Visual J++ environment.