| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> |
| <HEAD> |
| |
| <meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2005. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." > |
| |
| <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"> |
| <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> |
| |
| <LINK REL="STYLESHEET" HREF="../book.css" CHARSET="ISO-8859-1" TYPE="text/css"> |
| <TITLE> |
| Form control |
| </TITLE> |
| </HEAD> |
| <BODY BGCOLOR="#ffffff"> |
| |
| <H1> |
| Form control</H1> |
| <p><b>Form</b> is a basic control used to host UI Forms. It provides for setting |
| a title and scrolling the content similar to a Web browser. What makes forms |
| appealing is the fact that the content is an SWT composite that can be used as |
| you would use it in other contexts. For example, consider the following code |
| snippet:</p> |
| <blockquote> |
| <pre>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(); |
| } |
| }</pre> |
| </blockquote> |
| <p>UI Forms manipulate SWT widgets in a number of ways in order to achieve the |
| desired effect. For that reason, controls are typically created using the <code> |
| FormToolkit</code>. Normally an instance of a <code>ScrolledForm</code> is |
| created in order to get scrolling. When forms need to be nested, a <code>Form</code> |
| instance provides everything except for scrolling of the form content.</p> |
| <p>Form content is rendered below the title. SWT widgets are created in the form |
| using <code>Form.getBody()</code> as a parent.</p> |
| </BODY> |
| </HTML> |