Class VaadinIconAdapter

java.lang.Object
vaadinx.swing.VaadinIconAdapter
All Implemented Interfaces:
Icon

public final class VaadinIconAdapter extends Object implements Icon
Icon implementation that wraps a Vaadin VaadinIcon glyph. The bridge type that lets UIManager.getIcon(Object) return a Swing Icon whose payload is a Vaadin icon — no PNG raster, no server-side paint.

Path 2 of the icon-rendering plan: hand-picked UIManager.getIcon(String) keys map to VaadinIcon glyphs through this adapter, so dialog-heavy migrated code that pre-fetches an icon by key can install it on the same emulators that accept ImageIcon (Path 1) — JOptionPane / JLabel / JButton.

paintIcon(Component, Graphics, int, int) is intentionally a EHelper.onUnimplemented(String, String, Object...) stub: the adapter has no server-side raster to paint into a Graphics, and Path 3 (offscreen-paint of arbitrary Icon impls) is permanently deferred per R_match_swing_errors sub-bucket (b). The data path runs through EHelper.toVaadinIconComponent(String, Icon), which recognizes this adapter and forwards a fresh glyph.create() Icon to the peer's setIcon slot.

getIconWidth() / getIconHeight() report 16 — the BasicLookAndFeel small-icon convention. The actual rendered size comes from CSS on the produced Vaadin Icon component, not these values.

  • Constructor Details

    • VaadinIconAdapter

      public VaadinIconAdapter(com.vaadin.flow.component.icon.VaadinIcon glyph)
  • Method Details

    • getVaadinIcon

      public com.vaadin.flow.component.icon.VaadinIcon getVaadinIcon()
      The wrapped Vaadin icon enum value.
    • createComponent

      public com.vaadin.flow.component.Component createComponent()
      Build a fresh Vaadin Icon component for the wrapped glyph. A new instance per call — Vaadin components can only sit at one place in the DOM, so callers that install on multiple peers need independent components.
    • getIconWidth

      public int getIconWidth()
      Specified by:
      getIconWidth in interface Icon
    • getIconHeight

      public int getIconHeight()
      Specified by:
      getIconHeight in interface Icon
    • paintIcon

      public void paintIcon(Component c, Graphics g, int x, int y)
      Specified by:
      paintIcon in interface Icon
    • toString

      public String toString()
      Overrides:
      toString in class Object