Class GlassPane


public class GlassPane extends StyledElement<GlassPane>
A container that provides a glass pane overlay effect with a background tint layer.

The GlassPane creates a layered container with two internal panes:

  • Glass pane - A background layer that can be tinted with color and opacity
  • Content pane - A foreground layer where child elements are added

This is useful for creating modal dialogs, overlay effects, or frosted glass UI patterns. The glass pane sits behind the content, allowing you to apply semi-transparent colors or background images that show through the content area.

Usage Example:


 GlassPane overlay = new GlassPane(50, Color.BLACK);
 overlay.addElement(new Paragraph("Content on top of tinted background"));
 
Author:
Marvin P. Warble Jr.
See Also:
  • invalid reference
    Delegator
  • Constructor Details

    • GlassPane

      public GlassPane()
      Creates a new GlassPane with no tint or opacity applied.
    • GlassPane

      public GlassPane(int opacity, Color tint)
      Creates a new GlassPane with the specified opacity and tint color.
      Parameters:
      opacity - The opacity of the glass pane (0-100, where 0 is fully transparent).
      tint - The background tint color for the glass pane.
  • Method Details

    • create

      protected final void create()
      Description copied from class: Element
      Hook method called during element creation.

      Override this method to configure the element after initialization. This is called after Element.initialize() and only once during the element's lifecycle.

      Overrides:
      create in class Element<GlassPane>
    • addElement

      public final GlassPane addElement(Element child)
      Description copied from class: Element
      Adds a child element to this element.

      The child is removed from its previous parent if it has one, then added to this element's children. If this element is already attached to a page, the child is also attached and registered for DOM addition.

      Overrides:
      addElement in class Element<GlassPane>
      Parameters:
      child - The child element to add.
      Returns:
      this element for method chaining
    • setElement

      public final GlassPane setElement(Element child)
      Description copied from class: Element
      Replaces all child elements with a single child element.

      All existing children are removed before adding the new child.

      Overrides:
      setElement in class Element<GlassPane>
      Parameters:
      child - The child element to set as the only child.
      Returns:
      This element for method chaining.
    • insertElement

      public final GlassPane insertElement(int index, Element child)
      Description copied from class: Element
      Inserts a child element at the specified index.

      The child is removed from its previous parent if it has one, then inserted at the specified index in this element's children.

      Overrides:
      insertElement in class Element<GlassPane>
      Parameters:
      index - The index at which to insert the child.
      child - The child element to insert.
      Returns:
      this element for method chaining
    • removeAllElements

      public final void removeAllElements()
      Description copied from class: Element
      Removes all child elements from this element.

      Each child is unlinked and registered for DOM removal if the element is attached to a page.

      Overrides:
      removeAllElements in class Element<GlassPane>
    • removeElement

      public final void removeElement(String id)
      Description copied from class: Element
      Removes a child element by its ID.
      Overrides:
      removeElement in class Element<GlassPane>
      Parameters:
      id - The ID of the child element to remove.
    • removeElement

      public final void removeElement(Element child)
      Description copied from class: Element
      Removes a child element from this element.

      The child is unlinked from this parent and registered for DOM removal if the element is attached to a page.

      Overrides:
      removeElement in class Element<GlassPane>
      Parameters:
      child - The child element to remove.
    • setOpacity

      public final StyledElement setOpacity(int opacity)
      Sets the opacity of the glass pane layer.
      Overrides:
      setOpacity in class StyledElement<GlassPane>
      Parameters:
      opacity - The opacity value (0-100, where 0 is fully transparent).
      Returns:
      The glass pane element.
    • setBackground

      public final StyledElement setBackground(Color color)
      Sets the background color of the glass pane layer using a Color object.
      Overrides:
      setBackground in class StyledElement<GlassPane>
      Parameters:
      color - The background Color.
      Returns:
      The glass pane element.
    • setBackground

      public final StyledElement setBackground(String color)
      Sets the background of the glass pane layer using a CSS color string.
      Overrides:
      setBackground in class StyledElement<GlassPane>
      Parameters:
      color - The CSS background value (e.g., "#000000", "rgba(0,0,0,0.5)").
      Returns:
      The glass pane element.
    • setBackgroundColor

      public final StyledElement setBackgroundColor(Color color)
      Sets the background color of the glass pane layer using a Color object.
      Overrides:
      setBackgroundColor in class StyledElement<GlassPane>
      Parameters:
      color - The background Color.
      Returns:
      The glass pane element.
    • setBackgroundColor

      public final StyledElement setBackgroundColor(String color)
      Sets the background color of the glass pane layer using a CSS color string.
      Overrides:
      setBackgroundColor in class StyledElement<GlassPane>
      Parameters:
      color - The CSS color value (e.g., "#ffffff", "rgb(255,255,255)").
      Returns:
      The glass pane element.
    • setBackgroundImage

      public final StyledElement setBackgroundImage(String url)
      Sets the background image of the glass pane layer.
      Overrides:
      setBackgroundImage in class StyledElement<GlassPane>
      Parameters:
      url - The URL of the background image.
      Returns:
      The glass pane element.
    • setBackgroundPosition

      public final StyledElement setBackgroundPosition(String pos)
      Sets the background position of the glass pane layer.
      Overrides:
      setBackgroundPosition in class StyledElement<GlassPane>
      Parameters:
      pos - The CSS background position value (e.g., "center", "top left", "50% 50%").
      Returns:
      The glass pane element.
    • setBackgroundRepeat

      public final StyledElement setBackgroundRepeat(String repeat)
      Sets the background repeat behavior of the glass pane layer.
      Overrides:
      setBackgroundRepeat in class StyledElement<GlassPane>
      Parameters:
      repeat - The CSS background repeat value (e.g., "no-repeat", "repeat-x", "repeat-y").
      Returns:
      The glass pane element.
    • setBackgroundClip

      public StyledElement setBackgroundClip(String attrValue)
      Sets the background clip of the glass pane layer using a CSS string value.
      Overrides:
      setBackgroundClip in class StyledElement<GlassPane>
      Parameters:
      attrValue - The CSS background-clip value (e.g., "border-box", "padding-box", "content-box").
      Returns:
      The glass pane element.
    • setBackgroundClip

      public StyledElement setBackgroundClip(BackgroundClip attrValue)
      Sets the background clip of the glass pane layer using a BackgroundClip constant.
      Overrides:
      setBackgroundClip in class StyledElement<GlassPane>
      Parameters:
      attrValue - The BackgroundClip constant.
      Returns:
      The glass pane element.
    • setBackgroundOrigin

      public StyledElement setBackgroundOrigin(String attrValue)
      Sets the background origin of the glass pane layer using a CSS string value.
      Overrides:
      setBackgroundOrigin in class StyledElement<GlassPane>
      Parameters:
      attrValue - The CSS background-origin value (e.g., "border-box", "padding-box", "content-box").
      Returns:
      The glass pane element.
    • setBackgroundOrigin

      public StyledElement setBackgroundOrigin(BackgroundOrigin attrValue)
      Sets the background origin of the glass pane layer using a BackgroundOrigin constant.
      Overrides:
      setBackgroundOrigin in class StyledElement<GlassPane>
      Parameters:
      attrValue - The BackgroundOrigin constant.
      Returns:
      The glass pane element.
    • setBackgroundSize

      public StyledElement setBackgroundSize(String attrValue)
      Sets the background size of the glass pane layer using a CSS string value.
      Overrides:
      setBackgroundSize in class StyledElement<GlassPane>
      Parameters:
      attrValue - The CSS background-size value (e.g., "cover", "contain", "100px 200px").
      Returns:
      The glass pane element.
    • setBackgroundSize

      public StyledElement setBackgroundSize(BackgroundSize attrValue)
      Sets the background size of the glass pane layer using a BackgroundSize constant.
      Overrides:
      setBackgroundSize in class StyledElement<GlassPane>
      Parameters:
      attrValue - The BackgroundSize constant.
      Returns:
      The glass pane element.
    • setBackgroundSize

      public StyledElement setBackgroundSize(String width, String height)
      Sets the background size of the glass pane layer using CSS string width and height values.
      Overrides:
      setBackgroundSize in class StyledElement<GlassPane>
      Parameters:
      width - The CSS width value.
      height - The CSS height value.
      Returns:
      The glass pane element.
    • setBackgroundSize

      public StyledElement setBackgroundSize(int width, int height)
      Sets the background size of the glass pane layer using pixel width and height values.
      Overrides:
      setBackgroundSize in class StyledElement<GlassPane>
      Parameters:
      width - The width in pixels.
      height - The height in pixels.
      Returns:
      The glass pane element.
    • setBackgroundSize

      public StyledElement setBackgroundSize(Units width, Units height)
      Sets the background size of the glass pane layer using Units values for width and height.
      Overrides:
      setBackgroundSize in class StyledElement<GlassPane>
      Parameters:
      width - The width as a Units value.
      height - The height as a Units value.
      Returns:
      The glass pane element.