今天给大家分享的是由图老师小编精心为您推荐的Eclipse Form程序设计快速入门,喜欢的朋友可以分享一下,也算是给小编一份支持,大家都不容易啊!
【 tulaoshi.com - 编程语言 】
1、介绍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);
}
来源:http://www.tulaoshi.com/n/20160219/1599447.html
看过《Eclipse Form程序设计快速入门》的人还看了以下文章 更多>>