public class FormView extends ViewPart { private FormToolkit
toolkit; private ScrolledForm form;
/** * The
constructor. */ public FormView() {}
/** * This is a
callback that will allow us to create the viewer and * initialize
it. */ public void createPartControl(Composite parent)
{ toolkit = new FormToolkit(parent.getDisplay()); form =
toolkit.createScrolledForm(parent); form.setText("Hello, Eclipse
Forms"); }
/** * Passing the focus request to the
form. */ public void setFocus()
{ form.setFocus(); }
/** * Disposes the
toolkit */ public void dispose()
{ toolkit.dispose(); super.dispose(); } } 就象你在这段代码中看到一样,不需要太多就可以创建一个form.我们开始是创建一个toolkit实例().我们通过toolkit以提供的composite为parent来创建一个可以滚动的form.我们设置了form的标题.而且我们确定在需要的时候把focus传给form,当view
dispose时把toolkit也dispose掉。