Class Icons

java.lang.Object
com.vaadin.swingbridge.surrogates.util.Icons

public final class Icons extends Object
Icon → Vaadin bridge (icon-rendering Path 1). When the user's Icon is an ImageIcon, extract its raster, encode as PNG, and wrap it via Vaadin's byte-array Image ctor so the Swing-side icon reaches the Vaadin DOM as a real <img>. Other Icon impls (custom Path 3 paint callbacks, Vaadin-/Lumo-glyph keys for Path 2) WARN-and-drop — Path 1 is the in-scope slice.

Shared across both modules in the SD_shelper_statics-allowed direction — :emulators (EHelper, JComboBox) calls imageIconToVaadinImage(ImageIcon) for its own icon rendering, surrogates call toVaadinIconComponent(Object, Icon).

  • Method Details

    • toVaadinIconComponent

      public static com.vaadin.flow.component.Component toVaadinIconComponent(Object self, Icon icon)
      Convert a Swing Icon to a Vaadin Component suitable for Button.setIcon.
      • null → null (peers interpret as "remove icon").
      • ImageIcon → Image from Image(byte[], String) — wraps the icon's raster PNG-encoded with an inline-disposition download handler.
      • Anything else → SHelper.onUnimplemented(Object, String, Object...) + null: Path 2 (UIManager key → VaadinIcon) and Path 3 (offscreen BufferedImage paint of arbitrary Icon impls) are deferred.

      The self argument is the receiver instance for the WARN's class name; pass the surrogate / mixin owner. Caller is responsible for forwarding the result to the peer's Vaadin setIcon.

    • imageIconToVaadinImage

      public static com.vaadin.flow.component.html.Image imageIconToVaadinImage(ImageIcon icon)
      Encode an ImageIcon's raster as PNG and wrap it in a Vaadin Image via the byte[] ctor (auto-derives mime from the .png suffix and installs an inline-disposition DownloadHandler under the hood). Returns null when the icon is null or has no positive dimensions (e.g. a default- constructed ImageIcon that never loaded a source) — caller treats that as "no icon to install."

      If the icon carries a description, it overrides the default filename-as-alt the ctor sets.