logo.gif (3715 bytes)

 

How to integrate code from UIGen with your own code

When you press the Save button, UIGen will generate two files:
 
CODE FILE: Interface for use with event handling. This file will have the same name as the ordinary code file, except that it will be prefixed with ' I '.
INTERFACE FILE: Code to produce the user interface. The name of this file will be the name specified in the class field in the class tab with '.java' postfix.

The code file will contain code for declaration, positioning and adding of the controls. It will also contain code for event handling. The following code shows how to integrate this code file with your own:
 
  import waba.ui.* ;

  public class Test
  extends MainWindow
  implements ...
  {
    private UITest ui = new UITest() ;

    public Test()
     { ui.addTo( this ) ; }

     ....

  }

All the user interface controls in the class UITest will be added to the program.

To add event handling to the code, your class must implement the generated interface. In this example, the interface file looks like this:
 
  /* DO NOT MANUALLY EDIT THIS FILE!
  Interface code generated by
  UIGen by Andreas Bade
  1999/4/26 , 17:42:21 */

  public interface IUITest
  {
    public void btn1Pressed() ;
    public void btn2Pressed() ;
  }

Specify that your class will implement the interface:
 
  public class Test
  extends MainWindow
  implements IUITest
  {
    ....

    public void btn1Pressed()
    { ... }

    public void btn2Pressed()
    { ... }

    ....

  }

Then, call the method handEvent in the generated UI Class like in the following example:
 
  public class Test
  extends MainWindow
  implements IUITest
  {
    ...

    public void onEvent(Event event)
      { ui.handleEvent( event, this ) ; }

    ...

  }

The resulting code will look like this:
 
  import waba.ui.* ;

  public class Test
  extends MainWindow
  implements IUITest
  {
    private UITest ui = new UITest() ;

    public Test()
      { ui.addTo( this ) ; }

    public void onEvent(Event event)
      { ui.handleEvent( event, this ) ; }

    public void btn1Pressed()
    {
      // event handling for btn1
    }

    public void btn2Pressed()
    {
      // event handling for btn2
    }
  }

Using the user interface editor

The user interface editor lets you add components, and set their properties.
 
 

Properties

This tab lets you set common properties for a control.

The text property sets the text to be displayed on the control. For an edit field this means the text initially displayed in the field.

The name field is the name for the control in the generated code. The name should comply to ordinary conventions regarding object names. The first letters should be lowercase, some of the others may be uppercase. Never use space in this field. If you do so, the java compiler will produce an error.

The code field sets the method to be called when the user selects the control. For example, if you would like the method onBtnPushed() to be called when the user pressed a button, set the button's code property to 'onBtnPushed'. This will cause UIGen to generate event handling for the button.

The x, y, width and height fields sets the position and size for the control.

Class Tab

This tab sets the path and class name of the class to be generated. Use uppercase in the first name of the class name, and no spaces.

The Load button loads an already generated file. The Save button generated code for the class.
 
 

Add Tab

This tab lets you add different controls to the user interface.
 
 

Delete Tab

Use the Delete active button to delete the currently selected control. Use Delete all to delete all controls in the user interface.
 
 

Display Tab

This sets the display size for the user interface.