public class FormToolkit
extends java.lang.Object
In addition to being the control factory, the toolkit is also responsible for painting flat borders for select controls, managing hyperlink groups and control colors.
 The toolkit creates some of the most common controls used to populate Eclipse
 forms. Controls that must be created using their constructors,
 adapt() method is available to change its properties in the
 same way as with the supported toolkit controls.
 
Typically, one toolkit object is created per workbench part (for example, an editor or a form wizard). The toolkit is disposed when the part is disposed. To conserve resources, it is possible to create one color object for the entire plug-in and share it between several toolkits. The plug-in is responsible for disposing the colors (disposing the toolkit that uses shared color object will not dispose the colors).
 FormToolkit is normally instantiated, but can also be subclassed if some of
 the methods needs to be modified. In those cases, super must
 be called to preserve normal behaviour.
| Modifier and Type | Field and Description | 
|---|---|
| static java.lang.String | KEY_DRAW_BORDER | 
| static java.lang.String | TEXT_BORDER | 
| static java.lang.String | TREE_BORDER | 
| Constructor and Description | 
|---|
| FormToolkit(org.eclipse.swt.widgets.Display display)Creates a toolkit that is self-sufficient (will manage its own colors). | 
| FormToolkit(FormColors colors)Creates a toolkit that will use the provided (shared) colors. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | adapt(org.eclipse.swt.widgets.Composite composite)Adapts a composite to be used in a form associated with this toolkit. | 
| void | adapt(org.eclipse.swt.widgets.Control control,
     boolean trackFocus,
     boolean trackKeyboard)Adapts a control to be used in a form that is associated with this
 toolkit. | 
| org.eclipse.swt.widgets.Button | createButton(org.eclipse.swt.widgets.Composite parent,
            java.lang.String text,
            int style)Creates a button as a part of the form. | 
| org.eclipse.swt.widgets.Composite | createComposite(org.eclipse.swt.widgets.Composite parent)Creates the composite as a part of the form. | 
| org.eclipse.swt.widgets.Composite | createComposite(org.eclipse.swt.widgets.Composite parent,
               int style)Creates the composite as part of the form using the provided style. | 
| org.eclipse.swt.widgets.Composite | createCompositeSeparator(org.eclipse.swt.widgets.Composite parent)Creats the composite that can server as a separator between various parts
 of a form. | 
| org.eclipse.swt.widgets.Label | createLabel(org.eclipse.swt.widgets.Composite parent,
           java.lang.String text)Creates a label as a part of the form. | 
| org.eclipse.swt.widgets.Label | createLabel(org.eclipse.swt.widgets.Composite parent,
           java.lang.String text,
           int style)Creates a label as a part of the form. | 
| org.eclipse.swt.custom.ScrolledComposite | createScrolledForm(org.eclipse.swt.widgets.Composite parent)Creates a scrolled form widget in the provided parent. | 
| org.eclipse.swt.widgets.Label | createSeparator(org.eclipse.swt.widgets.Composite parent,
               int style)Creates a separator label as a part of the form. | 
| org.eclipse.swt.widgets.Table | createTable(org.eclipse.swt.widgets.Composite parent,
           int style)Creates a table as a part of the form. | 
| org.eclipse.swt.widgets.Text | createText(org.eclipse.swt.widgets.Composite parent,
          java.lang.String value)Creates a text as a part of the form. | 
| org.eclipse.swt.widgets.Text | createText(org.eclipse.swt.widgets.Composite parent,
          java.lang.String value,
          int style)Creates a text as a part of the form. | 
| org.eclipse.swt.widgets.Tree | createTree(org.eclipse.swt.widgets.Composite parent,
          int style)Creates a tree widget as a part of the form. | 
| void | dispose()Disposes the toolkit. | 
| static void | ensureVisible(org.eclipse.swt.widgets.Control c)A helper method that ensures the provided control is visible when
 ScrolledComposite is somewhere in the parent chain. | 
| int | getBorderMargin()Returns the margin required around the children whose border is being
 painted by the toolkit using  #paintBordersFor(Composite). | 
| int | getBorderStyle()Returns the border style used for various widgets created by this
 toolkit. | 
| FormColors | getColors()Returns the colors used by this toolkit. | 
| int | getOrientation()Returns the orientation that all the widgets created by this toolkit will
 inherit, if set. | 
| void | setBackground(org.eclipse.swt.graphics.Color bg)Sets the background color for the entire toolkit. | 
| void | setBorderStyle(int style)Sets the border style to be used when creating widgets. | 
| static void | setControlVisible(org.eclipse.swt.widgets.Control c,
                 boolean verticalOnly)A utility method that ensures that the control is visible in the scrolled
 composite. | 
| void | setOrientation(int orientation)Sets the orientation that all the widgets created by this toolkit will
 inherit. | 
public static final java.lang.String KEY_DRAW_BORDER
public static final java.lang.String TREE_BORDER
public static final java.lang.String TEXT_BORDER
public FormToolkit(org.eclipse.swt.widgets.Display display)
 Clients that call this method must call dispose() when they
 are finished using the toolkit.
public FormToolkit(FormColors colors)
markShared() method.
 
 Clients that call this method must call dispose() when they
 are finished using the toolkit.
colors - the shared colorspublic org.eclipse.swt.widgets.Button createButton(org.eclipse.swt.widgets.Composite parent,
                                                   java.lang.String text,
                                                   int style)
parent - the button parenttext - an optional text for the button (can be null)style - the button style (for example, SWT.PUSH)public org.eclipse.swt.widgets.Composite createComposite(org.eclipse.swt.widgets.Composite parent)
parent - the composite parentpublic org.eclipse.swt.widgets.Composite createComposite(org.eclipse.swt.widgets.Composite parent,
                                                         int style)
parent - the composite parentstyle - the composite stylepublic org.eclipse.swt.widgets.Composite createCompositeSeparator(org.eclipse.swt.widgets.Composite parent)
parent - the separator parentpublic org.eclipse.swt.widgets.Label createLabel(org.eclipse.swt.widgets.Composite parent,
                                                 java.lang.String text)
parent - the label parenttext - the label textpublic org.eclipse.swt.widgets.Label createLabel(org.eclipse.swt.widgets.Composite parent,
                                                 java.lang.String text,
                                                 int style)
parent - the label parenttext - the label textstyle - the label stylepublic void adapt(org.eclipse.swt.widgets.Control control,
                  boolean trackFocus,
                  boolean trackKeyboard)
control - a control to adapttrackFocus - if true, form will be scrolled horizontally
            and/or vertically if needed to ensure that the control is
            visible when it gains focus. Set it to false if
            the control is not capable of gaining focus.trackKeyboard - if true, the control that is capable of
            gaining focus will be tracked for certain keys that are
            important to the underlying form (for example, PageUp,
            PageDown, ScrollUp, ScrollDown etc.). Set it to
            false if the control is not capable of gaining
            focus or these particular key event are already used by the
            control.public void adapt(org.eclipse.swt.widgets.Composite composite)
composite - the composite to adaptpublic static void ensureVisible(org.eclipse.swt.widgets.Control c)
c - the control to revealpublic org.eclipse.swt.widgets.Label createSeparator(org.eclipse.swt.widgets.Composite parent,
                                                     int style)
parent - the separator parentstyle - the separator stylepublic org.eclipse.swt.widgets.Table createTable(org.eclipse.swt.widgets.Composite parent,
                                                 int style)
parent - the table parentstyle - the table stylepublic org.eclipse.swt.widgets.Text createText(org.eclipse.swt.widgets.Composite parent,
                                               java.lang.String value)
parent - the text parentvalue - the text initial valuepublic org.eclipse.swt.widgets.Text createText(org.eclipse.swt.widgets.Composite parent,
                                               java.lang.String value,
                                               int style)
parent - the text parentvalue - the text initial valuestyle - the text stylepublic org.eclipse.swt.widgets.Tree createTree(org.eclipse.swt.widgets.Composite parent,
                                               int style)
parent - the tree parentstyle - the tree stylepublic org.eclipse.swt.custom.ScrolledComposite createScrolledForm(org.eclipse.swt.widgets.Composite parent)
parent - the scrolled form parent#createFormpublic void dispose()
public void setBackground(org.eclipse.swt.graphics.Color bg)
bg - the new background colorpublic FormColors getColors()
public int getBorderStyle()
public int getBorderMargin()
#paintBordersFor(Composite). Since
 the border is painted around the controls on the parent, a number of
 pixels needs to be reserved for this border. For windowing systems where
 the native border is used, this margin is 0.public void setBorderStyle(int style)
style - SWT.BORDER or SWT.NULLgetBorderStyle()public static void setControlVisible(org.eclipse.swt.widgets.Control c,
                                     boolean verticalOnly)
c - the control to make visibleverticalOnly - if true, the scrolled composite will be
            scrolled only vertically if needed. Otherwise, the scrolled
            composite origin will be set to the control origin.public int getOrientation()
SWT.NULL,
 SWT.LEFT_TO_RIGHT and SWT.RIGHT_TO_LEFT.SWT.NULL if
         not set. The default orientation is inherited from the Window
         default orientation.Window.getDefaultOrientation()public void setOrientation(int orientation)
SWT.NULL, SWT.LEFT_TO_RIGHT
 and SWT.RIGHT_TO_LEFT.orientation - style for this toolkit.Copyright © 2007–2020. All rights reserved.