Class AbstractBorder

java.lang.Object
vaadinx.swing.border.AbstractBorder
All Implemented Interfaces:
Serializable, Border
Direct Known Subclasses:
BevelBorder, CompoundBorder, EmptyBorder, EtchedBorder, LineBorder, TitledBorder

public abstract class AbstractBorder extends Object implements Border, Serializable
Port of AbstractBorder — base class for every concrete border in this package plus the extension point user code subclasses for custom borders.

Adds a browser-side applyCss(com.vaadin.flow.dom.Element) template method on top of Swing's paint-only contract. Concrete borders override it to write the CSS representation of themselves onto the target element; vaadinx's JComponent.setBorder(Border) calls into that hook, so user code that writes panel.setBorder(new LineBorder(Color.BLACK)) sees the line actually render in the browser.

Custom user borders extending AbstractBorder without overriding applyCss won't render (R_best_effort_behaviour best-effort) — the base default clears any previously-installed border CSS and writes nothing. paintBorder(Component, Graphics, int, int, int, int) + getBorderInsets(Component) still work as on real Swing, so server-side code that reads insets or drives paint onto a Graphics sink keeps behaving the same.

See Also:
  • Constructor Details

    • AbstractBorder

      public AbstractBorder()
  • Method Details

    • paintBorder

      public void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
      Specified by:
      paintBorder in interface Border
    • getBorderInsets

      public Insets getBorderInsets(Component c)
      Specified by:
      getBorderInsets in interface Border
    • getBorderInsets

      public Insets getBorderInsets(Component c, Insets insets)
      Fill-the-arg variant of getBorderInsets — concrete borders override when they want to avoid the Insets allocation. Default reads getBorderInsets(vaadinx.awt.Component) and copies.
    • isBorderOpaque

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

      public void applyCss(com.vaadin.flow.dom.Element element)
      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 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.

    • clearBorderCss

      public static void clearBorderCss(com.vaadin.flow.dom.Element element)
      Remove every border-related inline style key that a concrete border from this package might have written. Called by both JComponent.setBorder(Border) (when the new border is null or custom) and every concrete border's applyCss(Element) before it writes its own keys.

      The whitelist covers the shorthand border, per-side border-top/right/bottom/left and their width/style/color longhands, border-radius, and padding + its four longhands. If a user also wrote one of these inline styles manually, it's cleared too — setBorder owns these CSS properties on a container.