양식은 UI 양식을 호스트하는 데 사용되는 기본 제어입니다. 제목 설정 및 웹 브라우저와 유사한 컨텐츠 화면 이동을 제공합니다. 양식을 돋보이게 만드는 것은 컨텐츠가 다른 컨텍스트에서 사용할 때 사용할 수 있는 SWT 컴포지트라는 사실입니다. 예를 들어, 다음 코드 스니펫을 고려하십시오.
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(); } }
UI 양식은 원하는 효과를 달성하기 위해 다양한 방법으로 SWT 위지트(widget)를
조작합니다. 그러한 이유로 제어는 일반적으로
FormToolkit
을 사용하여 작성됩니다. 보통 ScrolledForm
인스턴스는
화면 이동을 위해 작성됩니다. 양식이 중첩되어야 하는 경우, Form
인스턴스는 양식 컨텐츠 화면 이동을 제외한 모든 것을 제공합니다.
양식 컨텐츠는 제목 아래에 렌더링됩니다. SWT 위지트(widget)는
Form.getBody()
를 상위로 사용하여 양식에 작성됩니다.