To develop a new SWT Visual Beans Class, do the following:
- Create a Java™ project:
- From the Rational® Application Developer or WebSphere® Integration
Developer menu bar, select .
- In the dialog box that pops up, expand Java,
and select Java Project.
- Click Next and provide a name to the Project
name field.
- Click Finish.
- Add SWT Visual Bean and Standard Widget Toolkit (SWT) library to
the build path:
- Right-click project and select Properties.
- Select Java Build Path, and select Libraries tab,
and then click Add Library.
- Select SWT VisualBean, and click Next.
- Click Finish in the dialog that pops
up.
- Add Standard Widget Toolkit(SWT) library
to the build path in the same way.
- Create a visual class:
- Right-click the project, and select .
- 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.
- Click Finish. The visual class loads.
- Click the OpCompTest composite, and in the
Properties view, select layout, and then set the layout
to GridLayout.
- 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.
- 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());
}
}