public class formview extends viewpart {
 private formtoolkit toolkit;
 private scrolledform form;
 public void createpartcontrol(composite parent) {
  toolkit = new formtoolkit(parent.getdisplay());
  form = toolkit.createscrolledform(parent);
  form.settext("hello, eclipse forms");
 }
 public void setfocus() {
  form.setfocus();
 }
 public void dispose() {
  toolkit.dispose();
  super.dispose();
 }
}
<?xml version="1.0" encoding="utf-8"?>
<?eclipse version="3.0"?>
<plugin
id="formsamples"
name="formsamples plug-in"
version="1.0.0"
provider-name="nelson_tu"
class="org.xqtu.samples.formsamplesplugin">
<runtime>
<library name="formsamples.jar">
<export name="*"/>
</library>
</runtime>
<requires>
<import plugin="org.eclipse.ui"/>
<import plugin="org.eclipse.core.runtime"/>
<import plugin="org.eclipse.ui.forms"/>
</requires>
<extension
point="org.eclipse.ui.views">
<view
class="org.xqtu.samples.views.formview"
name="form sample"
id="formview"/>
</extension>
</plugin>
public void createpartcontrol(composite parent) {
 toolkit = new formtoolkit(parent.getdisplay());
 form = toolkit.createscrolledform(parent);
 form.settext("hello, eclipse forms");
 composite body = form.getbody();
 gridlayout layout = new gridlayout();
 body.setlayout(layout);
 hyperlink link = toolkit.createhyperlink(body, "click here.",swt.wrap);
 link.addhyperlinklistener(new hyperlinkadapter() {
  public void linkactivated(hyperlinkevent e) {
   system.out.println("link activated!");
  }
 });
}
public void createpartcontrol(composite parent) {
 toolkit = new formtoolkit(parent.getdisplay());
 form = toolkit.createscrolledform(parent);
 form.settext("hello, eclipse forms");
 composite body = form.getbody();
 gridlayout layout = new gridlayout();
 body.setlayout(layout);
 hyperlink link = toolkit.createhyperlink(body, "click here.",swt.wrap);
 link.addhyperlinklistener(new hyperlinkadapter() {
  public void linkactivated(hyperlinkevent e) {
   system.out.println("link activated!");
  }
 });
 layout.numcolumns = 2;
 griddata gd = new griddata();
 gd.horizontalspan = 2;
 link.setlayoutdata(gd);
 label label = toolkit.createlabel(body, "text field label:");
 text text = toolkit.createtext(body, "");
 text.setlayoutdata(new griddata(griddata.fill_horizontal));
 text.setdata(formtoolkit.key_draw_border, formtoolkit.text_border);
 button button = toolkit.createbutton(body,"an example of a checkbox in a form", swt.check);
 gd = new griddata();
 gd.horizontalspan = 2;
 button.setlayoutdata(gd);
 toolkit.paintbordersfor(body);
}
新闻热点
疑难解答