Class Toolkit
java.lang.Object
vaadinx.awt.Toolkit
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:
- Delegate to the headless JDK toolkit where the value is
client-independent and a headless JVM computes it correctly:
getFontMetrics(Font),getFontList(),getDesktopProperty(String),isAlwaysOnTopSupported(),getProperty(String, String)— verified to work underjava.awt.headless=true. - Browser-backed for genuinely client-specific facts the server
JVM cannot know (and which throw
HeadlessExceptionon the JDK toolkit):getScreenSize(),getScreenResolution(),getScreenInsets(GraphicsConfiguration),getMenuShortcutKeyMaskEx()— viaBrowserToolkitInfo(on-demand VT-park, D_toolkit_from_client_details). - Throw, faithful to the JDK contract:
getLockingKeyState(int)/setLockingKeyState(int, boolean)throwUnsupportedOperationException, exactly as a realToolkitdoes on a host that cannot toggle locking keys (R_match_swing_errors). - Fabricate a faithful constant for headless-throwing,
client-independent queries:
getColorModel()(default RGB),getMaximumCursorColors()/getBestCursorSize(int, int)(0 — "custom cursors unsupported"),getSystemSelection()(null). - WARN and ignore where there is no web counterpart:
beep()(web pages do not beep at users),setDynamicLayout(boolean),addAWTEventListener(AWTEventListener, long),mapInputMethodHighlight(InputMethodHighlight),getPrintJob(Frame, String, Properties)(printing deferred),createDragGestureRecognizer(Class, DragSource, Component, int, DragGestureListener)(DnD is theTransferHandlerpath). - Load images via
ImageIO(getImage(String)/createImage(String)) — headless-capable; theImageProduceroverload WARNs (producer pipeline is paint-scope, out of scope).
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 Summary
Modifier and TypeMethodDescriptionvoidaddAWTEventListener(AWTEventListener listener, long eventMask) voidbooleanvoidbeep()Web pages do not beep at users.intcheckImage(Image image, int width, int height, ImageObserver observer) Images loaded viaImageIOare already fully realised — all bits present.createCustomCursor(Image cursor, Point hotSpot, String name) Custom cursors are unsupported in the browser — returns the default cursor.<T extends DragGestureRecognizer>
TcreateDragGestureRecognizer(Class<T> abstractRecognizerClass, DragSource ds, Component c, int srcActions, DragGestureListener dgl) Drag-and-drop is theTransferHandlerpath (D_drag_and_drop), not this SPI.createImage(byte[] imagedata) createImage(byte[] imagedata, int imageoffset, int imagelength) createImage(ImageProducer producer) Producer-driven image creation is the paint pipeline — out of scope (R_match_swing_errors sub-bucket (b)).createImage(String filename) createImage(URL url) getAWTEventListeners(long eventMask) getBestCursorSize(int preferredWidth, int preferredHeight) Custom cursors are unsupported —(0,0), matching a minimal platform.The default RGB color model.static ToolkitThe toolkit for this application — a single global, stateless instance (per-UI clipboard / display state is resolved at call time viaUI.getCurrent()).getDesktopProperty(String propertyName) String[]getFontMetrics(Font font) booleangetLockingKeyState(int keyCode) intCustom cursors are unsupported — 0 colors, matching a minimal platform.intDeprecated.intThe accelerator modifier for menu shortcuts:METAon macOS / iOS,CTRLelsewhere.getPrintJob(Frame frame, String jobtitle, JobAttributes jobAttributes, PageAttributes pageAttributes) Printing is deferred.getPrintJob(Frame frame, String jobtitle, Properties props) Printing is deferred.static StringgetProperty(String key, String defaultValue) getPropertyChangeListeners(String propertyName) Screen insets (taskbar / dock reservation).intApproximate screen resolution in DPI (96 × devicePixelRatio).The browser viewport size (window.innerWidth/Height), NOT the physical monitor'sscreen.width/height— per D_toolkit_screen_size.The system clipboard for the current Vaadin UI.The system queue for this application — aEventQueuein ported types (R_no_vaadin_in_api limb 1), not the JDK toolkit's real queue.The selection clipboard ("primary selection", X11 middle-click).booleanbooleanbooleanisFrameStateSupported(int state) booleanisModalExclusionTypeSupported(Dialog.ModalExclusionType modalExclusionType) booleanisModalityTypeSupported(Dialog.ModalityType modalityType) Modal dialogs are supported (a UI fiber parks on them,Dialog.parkUntilClose).Map<TextAttribute, ?> mapInputMethodHighlight(InputMethodHighlight highlight) booleanprepareImage(Image image, int width, int height, ImageObserver observer) Images loaded viaImageIOare already fully realised — report loaded.voidremoveAWTEventListener(AWTEventListener listener) voidvoidsetDynamicLayout(boolean dynamic) voidsetLockingKeyState(int keyCode, boolean on) voidsync()Nothing to flush in a server-rendered context.
-
Method Details
-
getDefaultToolkit
The toolkit for this application — a single global, stateless instance (per-UI clipboard / display state is resolved at call time viaUI.getCurrent()). MirrorsToolkit.getDefaultToolkit(). -
getSystemClipboard
The system clipboard for the current Vaadin UI. Returns the sameWebClipboardinstance for repeated calls within one UI (per-UI lazy-init viaComponentUtil.setData(Component, SerializableTriConsumer, T, U)); separate UIs get separate instances. All instances ultimately route to the same browsernavigator.clipboard.Throws
IllegalStateExceptionifUI.getCurrent()is null — the per-UI lookup needs a UI to key on, and the WebClipboard's downstreamexecuteJsdispatch needs one anyway (D_clipboard, R_callswing_envelope). -
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
The browser viewport size (window.innerWidth/Height), NOT the physical monitor'sscreen.width/height— per D_toolkit_screen_size. The viewport is the coordinate spaceWindow.setLocation/setBoundsplaces 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; seeBrowserToolkitInfo. -
getScreenResolution
public int getScreenResolution()Approximate screen resolution in DPI (96 × devicePixelRatio). Browser-backed. -
getScreenInsets
Screen insets (taskbar / dock reservation). A browser has no such concept — always zero. Does not consultBrowserToolkitInfo(no browser round-trip needed). -
getMenuShortcutKeyMaskEx
public int getMenuShortcutKeyMaskEx()The accelerator modifier for menu shortcuts:METAon macOS / iOS,CTRLelsewhere. Browser-backed (platform fromBrowserToolkitInfo); defaults toCTRLuntil the browser value is available. -
getMenuShortcutKeyMask
Deprecated.Legacy mask form; prefergetMenuShortcutKeyMaskEx(). -
getLockingKeyState
public boolean getLockingKeyState(int keyCode) -
setLockingKeyState
public void setLockingKeyState(int keyCode, boolean on) -
getColorModel
The default RGB color model. -
getMaximumCursorColors
public int getMaximumCursorColors()Custom cursors are unsupported — 0 colors, matching a minimal platform. -
getBestCursorSize
Custom cursors are unsupported —(0,0), matching a minimal platform. -
isFrameStateSupported
public boolean isFrameStateSupported(int state) -
isModalityTypeSupported
Modal dialogs are supported (a UI fiber parks on them,Dialog.parkUntilClose). -
isModalExclusionTypeSupported
-
isDynamicLayoutActive
public boolean isDynamicLayoutActive() -
areExtraMouseButtonsEnabled
public boolean areExtraMouseButtonsEnabled() -
getFontMetrics
-
getFontList
-
getSystemEventQueue
The system queue for this application — aEventQueuein 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; seeEventQueue. -
getDesktopProperty
-
isAlwaysOnTopSupported
public boolean isAlwaysOnTopSupported() -
getProperty
-
getImage
-
getImage
-
createImage
-
createImage
-
createImage
-
createImage
-
createImage
Producer-driven image creation is the paint pipeline — out of scope (R_match_swing_errors sub-bucket (b)). -
prepareImage
Images loaded viaImageIOare already fully realised — report loaded. -
checkImage
Images loaded viaImageIOare 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
-
removeAWTEventListener
-
getAWTEventListeners
-
getAWTEventListeners
-
addPropertyChangeListener
-
removePropertyChangeListener
-
getPropertyChangeListeners
-
getPropertyChangeListeners
-
mapInputMethodHighlight
-
createCustomCursor
-
createDragGestureRecognizer
public <T extends DragGestureRecognizer> T createDragGestureRecognizer(Class<T> abstractRecognizerClass, DragSource ds, Component c, int srcActions, DragGestureListener dgl) Drag-and-drop is theTransferHandlerpath (D_drag_and_drop), not this SPI. -
getPrintJob
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.
-
getMenuShortcutKeyMaskEx().