Package com.google.gwt.user.client.ui

## Class DisclosurePanel

- java.lang.Object
- - com.google.gwt.user.client.ui.UIObject
  - - com.google.gwt.user.client.ui.Widget
    - - com.google.gwt.user.client.ui.Composite
      - - com.google.gwt.user.client.ui.DisclosurePanel

- All Implemented Interfaces:
    `HasAttachHandlers`, `HasCloseHandlers<DisclosurePanel>`, `HasOpenHandlers<DisclosurePanel>`, `HasHandlers`, `EventListener`, `FiresDisclosureEvents`, `HasAnimation`, `HasVisibility`, `HasWidgets`, `HasWidgets.ForIsWidget`, `IsRenderable`, `IsWidget`, `java.lang.Iterable<Widget>`

      public final class DisclosurePanel
      extends Composite
      implements FiresDisclosureEvents, HasWidgets.ForIsWidget, HasAnimation, HasOpenHandlers<DisclosurePanel>, HasCloseHandlers<DisclosurePanel>

  A widget that consists of a header and a content panel that discloses the content when a user clicks on the header.

  ### CSS Style Rules

  .gwt-DisclosurePanel
    the panel's primary style
  .gwt-DisclosurePanel-open
    dependent style set when panel is open
  .gwt-DisclosurePanel-closed
    dependent style set when panel is closed

  The header and content sections can be easily selected using css with a child selector:
  .gwt-DisclosurePanel-open .header { ... }

  ### Use in UiBinder Templates

  DisclosurePanel elements in `UiBinder` templates can have one widget child and one of two types of header elements. A <g:header> element can hold text (not html), or a <g:customHeader> element can hold a widget. (Note that the tags of the header elements are not capitalized. This is meant to signal that the header is not a runtime object, and so cannot have a `ui:field` attribute.)

  For example:

       <g:DisclosurePanel>
         <g:header>Text header</g:header>
         <g:Label>Widget body</g:Label>
       </g:DisclosurePanel>

       <g:DisclosurePanel>
         <g:customHeader>
           <g:Label>Widget header</g:Label>
         </g:customHeader>
         <g:Label>Widget body</g:Label>
       </g:DisclosurePanel>

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `(package private) static interface` | `DisclosurePanel.DefaultImages` |

    - ### Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject

      `UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled`

    - ### Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasWidgets

      `HasWidgets.ForIsWidget`

  - ### Field Summary

    - ### Fields inherited from class com.google.gwt.user.client.ui.Widget

      `eventsToSink`

    - ### Fields inherited from class com.google.gwt.user.client.ui.UIObject

      `DEBUG_ID_PREFIX, MISSING_ELEMENT_ERROR, SETELEMENT_TWICE_ERROR`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DisclosurePanel()` | Creates an empty DisclosurePanel that is initially closed.
    `DisclosurePanel​(ImageResource openImage, ImageResource closedImage, java.lang.String headerText)` | Creates a DisclosurePanel with the specified header text, an initial open/close state and a bundle of images to be used in the default header widget.
    `DisclosurePanel​(DisclosurePanelImages images, java.lang.String headerText, boolean isOpen)` | Deprecated. use `DisclosurePanel(ImageResource, ImageResource, String)` and `setOpen(boolean)`
    `DisclosurePanel​(Widget header)` | Deprecated. use `DisclosurePanel()` and `setHeader(Widget)`
    `DisclosurePanel​(Widget header, boolean isOpen)` | Deprecated. use `DisclosurePanel()`, `setOpen(boolean)` and `setHeader(Widget)` instead
    `DisclosurePanel​(java.lang.String headerText)` | Creates a DisclosurePanel that will be initially closed using the specified text in the header.
    `DisclosurePanel​(java.lang.String headerText, boolean isOpen)` | Deprecated. use `DisclosurePanel(String)` and `setOpen(boolean)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `add​(IsWidget w)` | Overloaded version for IsWidget.
    `void` | `add​(Widget w)` | Adds a child widget.
    `HandlerRegistration` | `addCloseHandler​(CloseHandler<DisclosurePanel> handler)` | Adds a `CloseEvent` handler.
    `void` | `addEventHandler​(DisclosureHandler handler)` | Deprecated. Use `addOpenHandler(OpenHandler)` and `addCloseHandler(CloseHandler)` instead
    `HandlerRegistration` | `addOpenHandler​(OpenHandler<DisclosurePanel> handler)` | Adds an `OpenEvent` handler.
    `void` | `clear()` | Removes all child widgets.
    `Widget` | `getContent()` | Gets the widget that was previously set in `setContent(Widget)`.
    `Widget` | `getHeader()` | Gets the widget that is currently being used as a header.
    `HasText` | `getHeaderTextAccessor()` | Gets a `HasText` instance to provide access to the headers's text, if the header widget does provide such access.
    `boolean` | `isAnimationEnabled()` | Returns true if animations are enabled, false if not.
    `boolean` | `isOpen()` | Determines whether the panel is open.
    `java.util.Iterator<Widget>` | `iterator()` | Gets an iterator for the contained widgets.
    `protected void` | `onEnsureDebugId​(java.lang.String baseID)` | Affected Elements: -header = the clickable header.
    `boolean` | `remove​(IsWidget w)` | Overloaded version for IsWidget.
    `boolean` | `remove​(Widget w)` | Removes a child widget.
    `void` | `removeEventHandler​(DisclosureHandler handler)` | Deprecated. Use the `HandlerRegistration.removeHandler()` method on the object returned by an add*Handler method instead
    `void` | `setAnimationEnabled​(boolean enable)` | Enable or disable animations.
    `void` | `setContent​(Widget content)` | Sets the content widget which can be opened and closed by this panel.
    `void` | `setHeader​(Widget headerWidget)` | Sets the widget used as the header for the panel.
    `void` | `setOpen​(boolean isOpen)` | Changes the visible state of this `DisclosurePanel`.

    - ### Methods inherited from class com.google.gwt.user.client.ui.Composite

      `claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidget`

    - ### Methods inherited from class com.google.gwt.user.client.ui.Widget

      `addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, ensureHandlers, fireEvent, getHandlerCount, getHandlerManager, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, replaceElement, setLayoutData, setParent, sinkEvents, unsinkEvents`

    - ### Methods inherited from class com.google.gwt.user.client.ui.UIObject

      `addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface com.google.gwt.event.shared.HasHandlers

      `fireEvent`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, spliterator`

- - ### Constructor Detail

    - #### DisclosurePanel

          public DisclosurePanel()

      Creates an empty DisclosurePanel that is initially closed.

    - #### DisclosurePanel

          @Deprecated
          public DisclosurePanel​(DisclosurePanelImages images,
                                 java.lang.String headerText,
                                 boolean isOpen)

      Deprecated.
      use `DisclosurePanel(ImageResource, ImageResource, String)` and `setOpen(boolean)`
      Creates a DisclosurePanel with the specified header text, an initial open/close state and a bundle of images to be used in the default header widget.
      Parameters:
        `images` - a bundle that provides disclosure panel specific images
        `headerText` - the text to be displayed in the header
        `isOpen` - the initial open/close state of the content panel

    - #### DisclosurePanel

          public DisclosurePanel​(ImageResource openImage,
                                 ImageResource closedImage,
                                 java.lang.String headerText)

      Creates a DisclosurePanel with the specified header text, an initial open/close state and a bundle of images to be used in the default header widget.
      Parameters:
        `openImage` - the open state image resource
        `closedImage` - the closed state image resource
        `headerText` - the text to be displayed in the header

    - #### DisclosurePanel

          public DisclosurePanel​(java.lang.String headerText)

      Creates a DisclosurePanel that will be initially closed using the specified text in the header.
      Parameters:
        `headerText` - the text to be displayed in the header

    - #### DisclosurePanel

          @Deprecated
          public DisclosurePanel​(java.lang.String headerText,
                                 boolean isOpen)

      Deprecated.
      use `DisclosurePanel(String)` and `setOpen(boolean)`
      Creates a DisclosurePanel with the specified header text and an initial open/close state.
      Parameters:
        `headerText` - the text to be displayed in the header
        `isOpen` - the initial open/close state of the content panel

    - #### DisclosurePanel

          @Deprecated
          public DisclosurePanel​(Widget header)

      Deprecated.
      use `DisclosurePanel()` and `setHeader(Widget)`
      Creates a DisclosurePanel that will be initially closed using a widget as the header.
      Parameters:
        `header` - the widget to be used as a header

    - #### DisclosurePanel

          @Deprecated
          public DisclosurePanel​(Widget header,
                                 boolean isOpen)

      Deprecated.
      use `DisclosurePanel()`, `setOpen(boolean)` and `setHeader(Widget)` instead
      Creates a DisclosurePanel using a widget as the header and an initial open/close state.
      Parameters:
        `header` - the widget to be used as a header
        `isOpen` - the initial open/close state of the content panel

  - ### Method Detail

    - #### add

          public void add​(Widget w)

      Description copied from interface: `HasWidgets`
      Adds a child widget.
      Specified by:
        `add` in interface `HasWidgets`
      Parameters:
        `w` - the widget to be added

    - #### add

          public void add​(IsWidget w)

      Overloaded version for IsWidget.
      Specified by:
        `add` in interface `HasWidgets.ForIsWidget`
      See Also:
        `add(Widget)`

    - #### addCloseHandler

          public HandlerRegistration addCloseHandler​(CloseHandler<DisclosurePanel> handler)

      Description copied from interface: `HasCloseHandlers`
      Adds a `CloseEvent` handler.
      Specified by:
        `addCloseHandler` in interface `HasCloseHandlers<DisclosurePanel>`
      Parameters:
        `handler` - the handler
      Returns:
        the registration for the event

    - #### addEventHandler

          @Deprecated
          public void addEventHandler​(DisclosureHandler handler)

      Deprecated.
      Use `addOpenHandler(OpenHandler)` and `addCloseHandler(CloseHandler)` instead
      Attaches an event handler to the panel to receive `DisclosureEvent` notification.
      Specified by:
        `addEventHandler` in interface `FiresDisclosureEvents`
      Parameters:
        `handler` - the handler to be added (should not be null)

    - #### addOpenHandler

          public HandlerRegistration addOpenHandler​(OpenHandler<DisclosurePanel> handler)

      Description copied from interface: `HasOpenHandlers`
      Adds an `OpenEvent` handler.
      Specified by:
        `addOpenHandler` in interface `HasOpenHandlers<DisclosurePanel>`
      Parameters:
        `handler` - the handler
      Returns:
        the registration for the event

    - #### clear

          public void clear()

      Description copied from interface: `HasWidgets`
      Removes all child widgets.
      Specified by:
        `clear` in interface `HasWidgets`

    - #### getContent

          public Widget getContent()

      Gets the widget that was previously set in `setContent(Widget)`.
      Returns:
        the panel's current content widget

    - #### getHeader

          public Widget getHeader()

      Gets the widget that is currently being used as a header.
      Returns:
        the widget currently being used as a header

    - #### getHeaderTextAccessor

          public HasText getHeaderTextAccessor()

      Gets a `HasText` instance to provide access to the headers's text, if the header widget does provide such access.
      Returns:
        a reference to the header widget if it implements `HasText`, `null` otherwise

    - #### isAnimationEnabled

          public boolean isAnimationEnabled()

      Description copied from interface: `HasAnimation`
      Returns true if animations are enabled, false if not.
      Specified by:
        `isAnimationEnabled` in interface `HasAnimation`

    - #### isOpen

          public boolean isOpen()

      Determines whether the panel is open.
      Returns:
        `true` if panel is in open state

    - #### iterator

          public java.util.Iterator<Widget> iterator()

      Description copied from interface: `HasWidgets`
      Gets an iterator for the contained widgets. This iterator is required to implement `Iterator.remove()`.
      Specified by:
        `iterator` in interface `HasWidgets`
      Specified by:
        `iterator` in interface `java.lang.Iterable<Widget>`

    - #### remove

          public boolean remove​(Widget w)

      Description copied from interface: `HasWidgets`
      Removes a child widget.
      Specified by:
        `remove` in interface `HasWidgets`
      Parameters:
        `w` - the widget to be removed
      Returns:
        `true` if the widget was present

    - #### remove

          public boolean remove​(IsWidget w)

      Overloaded version for IsWidget.
      Specified by:
        `remove` in interface `HasWidgets.ForIsWidget`
      See Also:
        `remove(Widget)`

    - #### removeEventHandler

          @Deprecated
          public void removeEventHandler​(DisclosureHandler handler)

      Deprecated.
      Use the `HandlerRegistration.removeHandler()` method on the object returned by an add*Handler method instead
      Removes an event handler from the panel.
      Specified by:
        `removeEventHandler` in interface `FiresDisclosureEvents`
      Parameters:
        `handler` - the handler to be removed

    - #### setAnimationEnabled

          public void setAnimationEnabled​(boolean enable)

      Description copied from interface: `HasAnimation`
      Enable or disable animations.
      Specified by:
        `setAnimationEnabled` in interface `HasAnimation`
      Parameters:
        `enable` - true to enable, false to disable

    - #### setContent

          public void setContent​(Widget content)

      Sets the content widget which can be opened and closed by this panel. If there is a preexisting content widget, it will be detached.
      Parameters:
        `content` - the widget to be used as the content panel

    - #### setHeader

          public void setHeader​(Widget headerWidget)

      Sets the widget used as the header for the panel.
      Parameters:
        `headerWidget` - the widget to be used as the header

    - #### setOpen

          public void setOpen​(boolean isOpen)

      Changes the visible state of this `DisclosurePanel`.
      Parameters:
        `isOpen` - `true` to open the panel, `false` to close

    - #### onEnsureDebugId

          protected void onEnsureDebugId​(java.lang.String baseID)

      Affected Elements:
      - -header = the clickable header.
      Overrides:
        `onEnsureDebugId` in class `UIObject`
      Parameters:
        `baseID` - the base ID used by the main element
      See Also:
        `UIObject.onEnsureDebugId(String)`