Class TitledBorder

java.lang.Object
vaadinx.swing.border.AbstractBorder
vaadinx.swing.border.TitledBorder
All Implemented Interfaces:
Serializable, Border

public class TitledBorder extends AbstractBorder
Port of TitledBorder. Wraps an inner border and adds a title label floating at the top edge.

CSS rendering is split in two: the border part lands via the inside border's own AbstractBorder.applyCss(Element) (LineBorder → border, EmptyBorder → padding, etc.). The title text is written as data-emul-border-title on the element, and the ::before pseudo-element rule is auto-injected once per UI by BorderCss.ensureTitledBorderStyleInjected(UI). The injection is idempotent — sentinel data on the UI gates duplicate writes — and survives even when applyCss is called outside a UI context (no-op then; lands on the next applyCss once a UI is current).

See Also:
  • Field Details

  • Constructor Details

    • TitledBorder

      public TitledBorder(String title)
    • TitledBorder

      public TitledBorder(Border border)
    • TitledBorder

      public TitledBorder(Border border, String title)
    • TitledBorder

      public TitledBorder(Border border, String title, int titleJustification, int titlePosition)
    • TitledBorder

      public TitledBorder(Border border, String title, int titleJustification, int titlePosition, Font titleFont)
    • TitledBorder

      public TitledBorder(Border border, String title, int titleJustification, int titlePosition, Font titleFont, Color titleColor)
  • Method Details

    • getTitle

      public String getTitle()
    • setTitle

      public void setTitle(String title)
    • getBorder

      public Border getBorder()
    • setBorder

      public void setBorder(Border border)
    • getTitlePosition

      public int getTitlePosition()
    • setTitlePosition

      public void setTitlePosition(int titlePosition)
    • getTitleJustification

      public int getTitleJustification()
    • setTitleJustification

      public void setTitleJustification(int titleJustification)
    • getTitleFont

      public Font getTitleFont()
    • setTitleFont

      public void setTitleFont(Font titleFont)
    • getTitleColor

      public Color getTitleColor()
    • setTitleColor

      public void setTitleColor(Color titleColor)
    • getBorderInsets

      public Insets getBorderInsets(Component c)
      Specified by:
      getBorderInsets in interface Border
      Overrides:
      getBorderInsets in class AbstractBorder
    • isBorderOpaque

      public boolean isBorderOpaque()
      Specified by:
      isBorderOpaque in interface Border
      Overrides:
      isBorderOpaque in class AbstractBorder
    • applyCss

      public void applyCss(com.vaadin.flow.dom.Element element)
      Description copied from class: AbstractBorder
      Write this border's CSS onto the target element. Called by JComponent.setBorder(Border). Concrete border classes override to emit the CSS that represents them (padding for EmptyBorder, border for LineBorder, per-side for MatteBorder, …). The base implementation clears any previously-installed border CSS via AbstractBorder.clearBorderCss(Element) and writes nothing, which is the honest behaviour for a user-authored custom AbstractBorder that didn't override this hook.

      Typical override: clearBorderCss(e); set("border", …);. Always clear first so a previous border's keys don't linger.

      Overrides:
      applyCss in class AbstractBorder