Developing a new SWT Visual Beans Class

To develop a new SWT Visual Beans Class, do the following:
  1. Create a Java™ project:
    1. From the Rational® Application Developer or WebSphere® Integration Developer menu bar, select File > New > Project.
    2. In the dialog box that pops up, expand Java, and select Java Project.
    3. Click Next and provide a name to the Project name field.
    4. Click Finish.
  2. Add SWT Visual Bean and Standard Widget Toolkit (SWT) library to the build path:
    1. Right-click project and select Properties.
    2. Select Java Build Path, and select Libraries tab, and then click Add Library.
    3. Select SWT VisualBean, and click Next.

      Screen capture showing how to add SWT VisualBean to the build path
    4. Click Finish in the dialog that pops up.

      Screen capture showing the build path will be updated to include SWT VisualBean
    5. Add Standard Widget Toolkit(SWT) library to the build path in the same way.
  3. Create a visual class:
    1. Right-click the project, and select New > Visual Class.
    2. In the dialog box that pops up, provide a name in the Name field, for example, OpCompTest and expand BTT Visual Beans in the Style box, and then select BTTOperationComposite. Check the public static void main(String[] args) (if you want to test through single class) and Inherited abstract methods checkboxes.

      Screen capture showing a new visual class
    3. Click Finish. The visual class loads.

      Screen capture showing that the visual class loads
  4. Click the OpCompTest composite, and in the Properties view, select layout, and then set the layout to GridLayout.
  5. Click BTTText in the Palette, and move your cursor to the OpCompTest composite you just created and drop the BTTText there. A dialog box pops up asking you to provide a name for the BTTText. You can name it to aBTTText, and click OK.
  6. The code is generated automatically as follows:
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.graphics.Point;
    import org.eclipse.swt.layout.GridLayout;
    import org.eclipse.swt.widgets.Composite;
    
    import com.ibm.btt.rcp.visualbean.BTTOperationComposite;
    import com.ibm.btt.rcp.visualbean.BTTText;
    
    public class OpCompTest extends BTTOperationComposite {
    
    	private BTTText aBTTText = null;
    
    	public OpCompTest(Composite parent, int style) {
    		super(parent, style);
    		initialize();
    	}
    
    	private void initialize() {
    		aBTTText = new BTTText(this, SWT.NONE);
    		setSize(new Point(300, 200));
    		setLayout(new GridLayout());
    	}
    
    }