Class Toolkit

java.lang.Object
vaadinx.awt.Toolkit

public final class Toolkit extends Object
Import-swap target for Toolkit — a full-surface emulator (D_toolkit_full_surface). Migrated code rewrites java.awt.Toolkit → vaadinx.awt.Toolkit and recompiles unchanged; the rule has no carve-out. Unlike a real Toolkit, this does not extend the abstract JDK class (it is the import-swap surface, not a platform toolkit), so it exposes only the public API and selects per-method behaviour by tier:

getDefaultToolkit() returns a single global, stateless instance — all per-UI state lives elsewhere (WebClipboard per UI, BrowserToolkitInfo per UI), looked up at call time via UI.getCurrent(). So obtaining the toolkit needs no UI (it works at frame-construction time); only the browser-touching calls do.

See D_toolkit_full_surface (full surface), D_clipboard (clipboard slice), D_whitelist_porting (port-surface policy).

  • Method Details

    • getDefaultToolkit

      public static Toolkit getDefaultToolkit()
      The toolkit for this application — a single global, stateless instance (per-UI clipboard / display state is resolved at call time via UI.getCurrent()). Mirrors Toolkit.getDefaultToolkit().
    • getSystemClipboard

      public Clipboard getSystemClipboard()
      The system clipboard for the current Vaadin UI. Returns the same WebClipboard instance for repeated calls within one UI (per-UI lazy-init via ComponentUtil.setData(Component, SerializableTriConsumer, T, U)); separate UIs get separate instances. All instances ultimately route to the same browser navigator.clipboard.

      Throws IllegalStateException if UI.getCurrent() is null — the per-UI lookup needs a UI to key on, and the WebClipboard's downstream executeJs dispatch needs one anyway (D_clipboard, R_callswing_envelope).

    • getSystemSelection

      public Clipboard getSystemSelection()
      The selection clipboard ("primary selection", X11 middle-click). No browser counterpart — returns null, which is the JDK's own behaviour on platforms without a selection clipboard.
    • getScreenSize

      public Dimension getScreenSize()
      The browser viewport size (window.innerWidth/Height), NOT the physical monitor's screen.width/height — per D_toolkit_screen_size. The viewport is the coordinate space Window.setLocation/setBounds places windows in, so migrated screen-math idioms (centering, edge-anchored toasts, size-to-fraction-of-screen) compute positions that land on the visible page. Browser-backed with live resize tracking; see BrowserToolkitInfo.
    • getScreenResolution

      public int getScreenResolution()
      Approximate screen resolution in DPI (96 × devicePixelRatio). Browser-backed.
    • getScreenInsets

      public Insets getScreenInsets(GraphicsConfiguration gc)
      Screen insets (taskbar / dock reservation). A browser has no such concept — always zero. Does not consult BrowserToolkitInfo (no browser round-trip needed).
    • getMenuShortcutKeyMaskEx

      public int getMenuShortcutKeyMaskEx()
      The accelerator modifier for menu shortcuts: META on macOS / iOS, CTRL elsewhere. Browser-backed (platform from BrowserToolkitInfo); defaults to CTRL until the browser value is available.
    • getMenuShortcutKeyMask

      @Deprecated public int getMenuShortcutKeyMask()
      Deprecated.
      Legacy mask form; prefer getMenuShortcutKeyMaskEx().
    • getLockingKeyState

      public boolean getLockingKeyState(int keyCode)
    • setLockingKeyState

      public void setLockingKeyState(int keyCode, boolean on)
    • getColorModel

      public ColorModel getColorModel()
      The default RGB color model.
    • getMaximumCursorColors

      public int getMaximumCursorColors()
      Custom cursors are unsupported — 0 colors, matching a minimal platform.
    • getBestCursorSize

      public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
      Custom cursors are unsupported — (0,0), matching a minimal platform.
    • isFrameStateSupported

      public boolean isFrameStateSupported(int state)
    • isModalityTypeSupported

      public boolean isModalityTypeSupported(Dialog.ModalityType modalityType)
      Modal dialogs are supported (a UI fiber parks on them, Dialog.parkUntilClose).
    • isModalExclusionTypeSupported

      public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType modalExclusionType)
    • isDynamicLayoutActive

      public boolean isDynamicLayoutActive()
    • areExtraMouseButtonsEnabled

      public boolean areExtraMouseButtonsEnabled()
    • getFontMetrics

      public FontMetrics getFontMetrics(Font font)
    • getFontList

      public String[] getFontList()
    • getSystemEventQueue

      public EventQueue getSystemEventQueue()
      The system queue for this application — a EventQueue in ported types (R_no_vaadin_in_api limb 1), not the JDK toolkit's real queue. Handing out the JDK's was doubly wrong: the type is uncallable from import-swapped code, and posting into a server JVM's AWT queue does nothing, where the ported queue's static EDT primitives reach the Vaadin UI thread. The instance methods that need an event pump WARN individually; see EventQueue.
    • getDesktopProperty

      public Object getDesktopProperty(String propertyName)
    • isAlwaysOnTopSupported

      public boolean isAlwaysOnTopSupported()
    • getProperty

      public static String getProperty(String key, String defaultValue)
    • getImage

      public Image getImage(String filename)
    • getImage

      public Image getImage(URL url)
    • createImage

      public Image createImage(String filename)
    • createImage

      public Image createImage(URL url)
    • createImage

      public Image createImage(byte[] imagedata)
    • createImage

      public Image createImage(byte[] imagedata, int imageoffset, int imagelength)
    • createImage

      public Image createImage(ImageProducer producer)
      Producer-driven image creation is the paint pipeline — out of scope (R_match_swing_errors sub-bucket (b)).
    • prepareImage

      public boolean prepareImage(Image image, int width, int height, ImageObserver observer)
      Images loaded via ImageIO are already fully realised — report loaded.
    • checkImage

      public int checkImage(Image image, int width, int height, ImageObserver observer)
      Images loaded via ImageIO are already fully realised — all bits present.
    • beep

      public void beep()
      Web pages do not beep at users. WARN and no-op.
    • sync

      public void sync()
      Nothing to flush in a server-rendered context. No-op (faithful).
    • setDynamicLayout

      public void setDynamicLayout(boolean dynamic)
    • addAWTEventListener

      public void addAWTEventListener(AWTEventListener listener, long eventMask)
    • removeAWTEventListener

      public void removeAWTEventListener(AWTEventListener listener)
    • getAWTEventListeners

      public AWTEventListener[] getAWTEventListeners()
    • getAWTEventListeners

      public AWTEventListener[] getAWTEventListeners(long eventMask)
    • addPropertyChangeListener

      public void addPropertyChangeListener(String name, PropertyChangeListener pcl)
    • removePropertyChangeListener

      public void removePropertyChangeListener(String name, PropertyChangeListener pcl)
    • getPropertyChangeListeners

      public PropertyChangeListener[] getPropertyChangeListeners()
    • getPropertyChangeListeners

      public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
    • mapInputMethodHighlight

      public Map<TextAttribute, ?> mapInputMethodHighlight(InputMethodHighlight highlight)
    • createCustomCursor

      public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
      Custom cursors are unsupported in the browser — returns the default cursor.
    • createDragGestureRecognizer

      public <T extends DragGestureRecognizer> T createDragGestureRecognizer(Class<T> abstractRecognizerClass, DragSource ds, Component c, int srcActions, DragGestureListener dgl)
      Drag-and-drop is the TransferHandler path (D_drag_and_drop), not this SPI.
    • getPrintJob

      public PrintJob getPrintJob(Frame frame, String jobtitle, Properties props)
      Printing is deferred. Returns null — the JDK's own "user cancelled" result.
    • getPrintJob

      public PrintJob getPrintJob(Frame frame, String jobtitle, JobAttributes jobAttributes, PageAttributes pageAttributes)
      Printing is deferred. Returns null — the JDK's own "user cancelled" result.