Package: groovy.swing.factory

## [Groovy] Class WidgetFactory

- groovy.swing.factory.WidgetFactory

-     class WidgetFactory
      extends AbstractFactory

  Factory that accepts pre-existing widget instances of a restricted type.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected boolean` | `leaf` | Whether created nodes are treated as leaves.

  - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `Class` | `restrictedType` Accepted runtime type for node values.

  - ### Constructor Summary

    Constructors
    Constructor and description
    `WidgetFactory(Class restrictedType, boolean leaf)` Creates a new factory that accepts pre-existing widget instances of a restricted type.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `boolean` | `isLeaf()` Indicates whether nodes created by this factory accept children.
    `` | `Object` | `newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes)` Creates the node handled by this factory.
    `` | `void` | `setChild(FactoryBuilderSupport builder, Object parent, Object child)` Attaches a child node to its parent.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class AbstractFactory` | `isHandlesNodeChildren, isLeaf, onFactoryRegistration, onHandleNodeAttributes, onNodeChildren, onNodeCompleted, setChild, setParent`

- - ### Field Detail

    - #### protected final boolean leaf

      Whether created nodes are treated as leaves.

  - ### Property Detail

    - #### final Class restrictedType

      Accepted runtime type for node values.

  - ### Constructor Detail

    - #### WidgetFactory(Class restrictedType, boolean leaf)

      Creates a new factory that accepts pre-existing widget instances of a restricted type.

      Parameters:
        `restrictedType` - the accepted widget type
        `leaf` - whether created nodes are leaf nodes

  - ### Method Detail

    - #### boolean isLeaf()

      Indicates whether nodes created by this factory accept children.

      Returns:
        true if child nodes are not expected

    - #### Object newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes)

      Creates the node handled by this factory.

      Parameters:
        `builder` - the factory builder
        `name` - the node name
        `value` - the node value
        `attributes` - the node attributes
      Returns:
        the created or reused node

    - #### void setChild(FactoryBuilderSupport builder, Object parent, Object child)

      Attaches a child node to its parent.

      Parameters:
        `builder` - the factory builder
        `parent` - the parent node
        `child` - the child node