Package-level declarations
Bindings for JAWT - access to the native structures behind AWT (java.awt), used for native rendering onto a component or for hand-off of a native window to AWT.
Constants and versions
All constants live on the JAWT object:
Versions: JAWT.v3 (1.3), JAWT.v4 (1.4), JAWT.v7 (1.7), JAWT.v9 (9). Pass one to getAwt / withAwt; newer versions unlock extra entry points (
Lock/Unlock/GetComponentfrom 1.4, embedding from 9).Lock result flags returned by DrawingSurface.lock: JAWT.LOCK_ERROR, JAWT.LOCK_CLIP_CHANGED, JAWT.LOCK_BOUNDS_CHANGED, JAWT.LOCK_SURFACE_CHANGED.
Typical rendering loop
Obtain the Awt interface, take a DrawingSurface for a java.awt.Component (usually a Canvas or Window), lock it, and read the platform-specific DrawingSurfaceInfo. Session helpers acquire and release everything for you:
// context(env: JniEnv, memScope: MemScope)
withAwt(JAWT.v9) { awt ->
awt.useDrawingSurface(component) { surface ->
surface.locking {
surface.useInfo { info ->
// info.bounds, info.clipRects, ...
// platform members: hwnd/hdc on Windows, display/drawable on Linux, layer on macOS
// draw...
}
}
}
}Or in one call: Awt.useDrawingSurfaceInfo.
All operations on a DrawingSurface must run on the same thread that obtained it via getDrawingSurface. When calling lock / unlock / getInfo / freeInfo from another thread, set DrawingSurface.env to that thread's JniEnv first.
Session helpers
| Helper | Role |
|---|---|
| withAwt | getAwt + throw if the VM does not expose JAWT |
| Awt.locking | lock / unlock the entire AWT (since 1.4) |
| Awt.useDrawingSurface | getDrawingSurface + freeDrawingSurface |
| DrawingSurface.locking | lock + unlock; throws on JAWT.LOCK_ERROR |
| DrawingSurface.useInfo | getInfo + freeInfo |
| Awt.useDrawingSurfaceInfo | surface + lock + info stacked together |
Low-level entry points (getAwt, getDrawingSurface, lock, getInfo, …) remain available when you need finer control or want to cache the surface across frames.
Embedding a native window into AWT
Since JAWT 9, a native container can host an AWT Frame:
Awt.createEmbeddedFrame - create a
java.awt.Frameinside a native parent (HWND / Drawable / NSWindow).Awt.setBounds - move/resize that embedded frame relative to the native parent (
Component.setBoundsalone keeps embedded frames at(0, 0)for compatibility).Awt.synthesizeWindowActivation - synthesize activate / deactivate for the embedded frame.
The reverse direction - resolve a java.awt.Component from a native handle - is Awt.getComponent (since 1.4).
Platform handles passed to embedding / getComponent:
| Platform | Handle |
|---|---|
| Windows | HWND |
| Linux | X11 Drawable |
| macOS | NSWindow |
Platform-specific DrawingSurfaceInfo members
Each desktop source set exposes the native structure members directly on DrawingSurfaceInfo - no platformInfo cast:
Windows (mingwMain):
hwnd - window handle (mutually exclusive with hbitmap / pbits)
hbitmap - DDB handle
pbits - DIB bits pointer
hdc - preferred device context (use instead of
BeginPaint/GetDC)hpalette
Linux (linuxMain):
drawable, display, visualID, colormapID, depth
GetAWTColor - RGB → pixel for paletted modes (since 1.4)
macOS (macosMain):
layer / windowLayer -
CALayerof the surface / window
Types
DrawingSurface - drawing surface of a JAwtComponent; must be freed with freeDrawingSurface.
DrawingSurfaceInfo - bounds, clip rectangles (clipRects / clipSize) and platform info; must be freed with freeInfo.
AwtRectangle -
{ x, y, width, height }used by bounds and clip.JAwtComponent / JAwtFrame - typed JObject aliases for
java.awt.Component/java.awt.Frame.
Bindings for JAWT - access to the native structures behind AWT (java.awt), used for native rendering onto a component or for hand-off of a native window to AWT.
Constants and versions
All constants live on the JAWT object:
Versions: JAWT.v3 (1.3), JAWT.v4 (1.4), JAWT.v7 (1.7), JAWT.v9 (9). Pass one to getAwt / withAwt; newer versions unlock extra entry points (
Lock/Unlock/GetComponentfrom 1.4, embedding from 9).Lock result flags returned by DrawingSurface.lock: JAWT.LOCK_ERROR, JAWT.LOCK_CLIP_CHANGED, JAWT.LOCK_BOUNDS_CHANGED, JAWT.LOCK_SURFACE_CHANGED.
Typical rendering loop
Obtain the Awt interface, take a DrawingSurface for a java.awt.Component (usually a Canvas or Window), lock it, and read the platform-specific DrawingSurfaceInfo. Session helpers acquire and release everything for you:
// context(env: JniEnv, memScope: MemScope)
withAwt(JAWT.v9) { awt ->
awt.useDrawingSurface(component) { surface ->
surface.locking {
surface.useInfo { info ->
// info.bounds, info.clipRects, ...
// platform members: hwnd/hdc on Windows, display/drawable on Linux, layer on macOS
// draw...
}
}
}
}Or in one call: Awt.useDrawingSurfaceInfo.
All operations on a DrawingSurface must run on the same thread that obtained it via getDrawingSurface. When calling lock / unlock / getInfo / freeInfo from another thread, set DrawingSurface.env to that thread's JniEnv first.
Session helpers
| Helper | Role |
|---|---|
| withAwt | getAwt + throw if the VM does not expose JAWT |
| Awt.locking | lock / unlock the entire AWT (since 1.4) |
| Awt.useDrawingSurface | getDrawingSurface + freeDrawingSurface |
| DrawingSurface.locking | lock + unlock; throws on JAWT.LOCK_ERROR |
| DrawingSurface.useInfo | getInfo + freeInfo |
| Awt.useDrawingSurfaceInfo | surface + lock + info stacked together |
Low-level entry points (getAwt, getDrawingSurface, lock, getInfo, …) remain available when you need finer control or want to cache the surface across frames.
Embedding a native window into AWT
Since JAWT 9, a native container can host an AWT Frame:
Awt.createEmbeddedFrame - create a
java.awt.Frameinside a native parent (HWND / Drawable / NSWindow).Awt.setBounds - move/resize that embedded frame relative to the native parent (
Component.setBoundsalone keeps embedded frames at(0, 0)for compatibility).Awt.synthesizeWindowActivation - synthesize activate / deactivate for the embedded frame.
The reverse direction - resolve a java.awt.Component from a native handle - is Awt.getComponent (since 1.4).
Platform handles passed to embedding / getComponent:
| Platform | Handle |
|---|---|
| Windows | HWND |
| Linux | X11 Drawable |
| macOS | NSWindow |
Platform-specific DrawingSurfaceInfo members
Each desktop source set exposes the native structure members directly on DrawingSurfaceInfo - no platformInfo cast:
Windows (mingwMain):
hwnd - window handle (mutually exclusive with hbitmap / pbits)
hbitmap - DDB handle
pbits - DIB bits pointer
hdc - preferred device context (use instead of
BeginPaint/GetDC)hpalette
Linux (linuxMain):
GetAWTColor - RGB → pixel for paletted modes (since 1.4)
macOS (macosMain):
layer / windowLayer -
CALayerof the surface / window
Types
DrawingSurface - drawing surface of a JAwtComponent; must be freed with freeDrawingSurface.
DrawingSurfaceInfo - bounds, clip rectangles (clipRects / clipSize) and platform info; must be freed with freeInfo.
AwtRectangle -
{ x, y, width, height }used by bounds and clip.JAwtComponent / JAwtFrame - typed JObject aliases for
java.awt.Component/java.awt.Frame.
Bindings for JAWT - access to the native structures behind AWT (java.awt), used for native rendering onto a component or for hand-off of a native window to AWT.
Constants and versions
All constants live on the JAWT object:
Versions: JAWT.v3 (1.3), JAWT.v4 (1.4), JAWT.v7 (1.7), JAWT.v9 (9). Pass one to getAwt / withAwt; newer versions unlock extra entry points (
Lock/Unlock/GetComponentfrom 1.4, embedding from 9).Lock result flags returned by DrawingSurface.lock: JAWT.LOCK_ERROR, JAWT.LOCK_CLIP_CHANGED, JAWT.LOCK_BOUNDS_CHANGED, JAWT.LOCK_SURFACE_CHANGED.
Typical rendering loop
Obtain the Awt interface, take a DrawingSurface for a java.awt.Component (usually a Canvas or Window), lock it, and read the platform-specific DrawingSurfaceInfo. Session helpers acquire and release everything for you:
// context(env: JniEnv, memScope: MemScope)
withAwt(JAWT.v9) { awt ->
awt.useDrawingSurface(component) { surface ->
surface.locking {
surface.useInfo { info ->
// info.bounds, info.clipRects, ...
// platform members: hwnd/hdc on Windows, display/drawable on Linux, layer on macOS
// draw...
}
}
}
}Or in one call: Awt.useDrawingSurfaceInfo.
All operations on a DrawingSurface must run on the same thread that obtained it via getDrawingSurface. When calling lock / unlock / getInfo / freeInfo from another thread, set DrawingSurface.env to that thread's JniEnv first.
Session helpers
| Helper | Role |
|---|---|
| withAwt | getAwt + throw if the VM does not expose JAWT |
| Awt.locking | lock / unlock the entire AWT (since 1.4) |
| Awt.useDrawingSurface | getDrawingSurface + freeDrawingSurface |
| DrawingSurface.locking | lock + unlock; throws on JAWT.LOCK_ERROR |
| DrawingSurface.useInfo | getInfo + freeInfo |
| Awt.useDrawingSurfaceInfo | surface + lock + info stacked together |
Low-level entry points (getAwt, getDrawingSurface, lock, getInfo, …) remain available when you need finer control or want to cache the surface across frames.
Embedding a native window into AWT
Since JAWT 9, a native container can host an AWT Frame:
Awt.createEmbeddedFrame - create a
java.awt.Frameinside a native parent (HWND / Drawable / NSWindow).Awt.setBounds - move/resize that embedded frame relative to the native parent (
Component.setBoundsalone keeps embedded frames at(0, 0)for compatibility).Awt.synthesizeWindowActivation - synthesize activate / deactivate for the embedded frame.
The reverse direction - resolve a java.awt.Component from a native handle - is Awt.getComponent (since 1.4).
Platform handles passed to embedding / getComponent:
| Platform | Handle |
|---|---|
| Windows | HWND |
| Linux | X11 Drawable |
| macOS | NSWindow |
Platform-specific DrawingSurfaceInfo members
Each desktop source set exposes the native structure members directly on DrawingSurfaceInfo - no platformInfo cast:
Windows (mingwMain):
hwnd - window handle (mutually exclusive with hbitmap / pbits)
hbitmap - DDB handle
pbits - DIB bits pointer
hdc - preferred device context (use instead of
BeginPaint/GetDC)hpalette
Linux (linuxMain):
drawable, display, visualID, colormapID, depth
GetAWTColor - RGB → pixel for paletted modes (since 1.4)
macOS (macosMain):
layer / windowLayer -
CALayerof the surface / window
Types
DrawingSurface - drawing surface of a JAwtComponent; must be freed with freeDrawingSurface.
DrawingSurfaceInfo - bounds, clip rectangles (clipRects / clipSize) and platform info; must be freed with freeInfo.
AwtRectangle -
{ x, y, width, height }used by bounds and clip.JAwtComponent / JAwtFrame - typed JObject aliases for
java.awt.Component/java.awt.Frame.
Bindings for JAWT - access to the native structures behind AWT (java.awt), used for native rendering onto a component or for hand-off of a native window to AWT.
Constants and versions
All constants live on the JAWT object:
Versions: JAWT.v3 (1.3), JAWT.v4 (1.4), JAWT.v7 (1.7), JAWT.v9 (9). Pass one to getAwt / withAwt; newer versions unlock extra entry points (
Lock/Unlock/GetComponentfrom 1.4, embedding from 9).Lock result flags returned by DrawingSurface.lock: JAWT.LOCK_ERROR, JAWT.LOCK_CLIP_CHANGED, JAWT.LOCK_BOUNDS_CHANGED, JAWT.LOCK_SURFACE_CHANGED.
Typical rendering loop
Obtain the Awt interface, take a DrawingSurface for a java.awt.Component (usually a Canvas or Window), lock it, and read the platform-specific DrawingSurfaceInfo. Session helpers acquire and release everything for you:
// context(env: JniEnv, memScope: MemScope)
withAwt(JAWT.v9) { awt ->
awt.useDrawingSurface(component) { surface ->
surface.locking {
surface.useInfo { info ->
// info.bounds, info.clipRects, ...
// platform members: hwnd/hdc on Windows, display/drawable on Linux, layer on macOS
// draw...
}
}
}
}Or in one call: Awt.useDrawingSurfaceInfo.
All operations on a DrawingSurface must run on the same thread that obtained it via getDrawingSurface. When calling lock / unlock / getInfo / freeInfo from another thread, set DrawingSurface.env to that thread's JniEnv first.
Session helpers
| Helper | Role |
|---|---|
| withAwt | getAwt + throw if the VM does not expose JAWT |
| Awt.locking | lock / unlock the entire AWT (since 1.4) |
| Awt.useDrawingSurface | getDrawingSurface + freeDrawingSurface |
| DrawingSurface.locking | lock + unlock; throws on JAWT.LOCK_ERROR |
| DrawingSurface.useInfo | getInfo + freeInfo |
| Awt.useDrawingSurfaceInfo | surface + lock + info stacked together |
Low-level entry points (getAwt, getDrawingSurface, lock, getInfo, …) remain available when you need finer control or want to cache the surface across frames.
Embedding a native window into AWT
Since JAWT 9, a native container can host an AWT Frame:
Awt.createEmbeddedFrame - create a
java.awt.Frameinside a native parent (HWND / Drawable / NSWindow).Awt.setBounds - move/resize that embedded frame relative to the native parent (
Component.setBoundsalone keeps embedded frames at(0, 0)for compatibility).Awt.synthesizeWindowActivation - synthesize activate / deactivate for the embedded frame.
The reverse direction - resolve a java.awt.Component from a native handle - is Awt.getComponent (since 1.4).
Platform handles passed to embedding / getComponent:
| Platform | Handle |
|---|---|
| Windows | HWND |
| Linux | X11 Drawable |
| macOS | NSWindow |
Platform-specific DrawingSurfaceInfo members
Each desktop source set exposes the native structure members directly on DrawingSurfaceInfo - no platformInfo cast:
Windows (mingwMain):
hwnd - window handle (mutually exclusive with hbitmap / pbits)
hbitmap - DDB handle
pbits - DIB bits pointer
hdc - preferred device context (use instead of
BeginPaint/GetDC)
Linux (linuxMain):
drawable, display, visualID, colormapID, depth
GetAWTColor - RGB → pixel for paletted modes (since 1.4)
macOS (macosMain):
layer / windowLayer -
CALayerof the surface / window
Types
DrawingSurface - drawing surface of a JAwtComponent; must be freed with freeDrawingSurface.
DrawingSurfaceInfo - bounds, clip rectangles (clipRects / clipSize) and platform info; must be freed with freeInfo.
AwtRectangle -
{ x, y, width, height }used by bounds and clip.JAwtComponent / JAwtFrame - typed JObject aliases for
java.awt.Component/java.awt.Frame.
Bindings for JAWT - access to the native structures behind AWT (java.awt), used for native rendering onto a component or for hand-off of a native window to AWT.
Constants and versions
All constants live on the JAWT object:
Versions: JAWT.v3 (1.3), JAWT.v4 (1.4), JAWT.v7 (1.7), JAWT.v9 (9). Pass one to getAwt / withAwt; newer versions unlock extra entry points (
Lock/Unlock/GetComponentfrom 1.4, embedding from 9).Lock result flags returned by DrawingSurface.lock: JAWT.LOCK_ERROR, JAWT.LOCK_CLIP_CHANGED, JAWT.LOCK_BOUNDS_CHANGED, JAWT.LOCK_SURFACE_CHANGED.
Typical rendering loop
Obtain the Awt interface, take a DrawingSurface for a java.awt.Component (usually a Canvas or Window), lock it, and read the platform-specific DrawingSurfaceInfo. Session helpers acquire and release everything for you:
// context(env: JniEnv, memScope: MemScope)
withAwt(JAWT.v9) { awt ->
awt.useDrawingSurface(component) { surface ->
surface.locking {
surface.useInfo { info ->
// info.bounds, info.clipRects, ...
// platform members: hwnd/hdc on Windows, display/drawable on Linux, layer on macOS
// draw...
}
}
}
}Or in one call: Awt.useDrawingSurfaceInfo.
All operations on a DrawingSurface must run on the same thread that obtained it via getDrawingSurface. When calling lock / unlock / getInfo / freeInfo from another thread, set DrawingSurface.env to that thread's JniEnv first.
Session helpers
| Helper | Role |
|---|---|
| withAwt | getAwt + throw if the VM does not expose JAWT |
| Awt.locking | lock / unlock the entire AWT (since 1.4) |
| Awt.useDrawingSurface | getDrawingSurface + freeDrawingSurface |
| DrawingSurface.locking | lock + unlock; throws on JAWT.LOCK_ERROR |
| DrawingSurface.useInfo | getInfo + freeInfo |
| Awt.useDrawingSurfaceInfo | surface + lock + info stacked together |
Low-level entry points (getAwt, getDrawingSurface, lock, getInfo, …) remain available when you need finer control or want to cache the surface across frames.
Embedding a native window into AWT
Since JAWT 9, a native container can host an AWT Frame:
Awt.createEmbeddedFrame - create a
java.awt.Frameinside a native parent (HWND / Drawable / NSWindow).Awt.setBounds - move/resize that embedded frame relative to the native parent (
Component.setBoundsalone keeps embedded frames at(0, 0)for compatibility).Awt.synthesizeWindowActivation - synthesize activate / deactivate for the embedded frame.
The reverse direction - resolve a java.awt.Component from a native handle - is Awt.getComponent (since 1.4).
Platform handles passed to embedding / getComponent:
| Platform | Handle |
|---|---|
| Windows | HWND |
| Linux | X11 Drawable |
| macOS | NSWindow |
Platform-specific DrawingSurfaceInfo members
Each desktop source set exposes the native structure members directly on DrawingSurfaceInfo - no platformInfo cast:
Windows (mingwMain):
hwnd - window handle (mutually exclusive with hbitmap / pbits)
hbitmap - DDB handle
pbits - DIB bits pointer
hdc - preferred device context (use instead of
BeginPaint/GetDC)hpalette
Linux (linuxMain):
drawable, display, visualID, colormapID, depth
GetAWTColor - RGB → pixel for paletted modes (since 1.4)
macOS (macosMain):
layer / windowLayer -
CALayerof the surface / window
Types
DrawingSurface - drawing surface of a JAwtComponent; must be freed with freeDrawingSurface.
DrawingSurfaceInfo - bounds, clip rectangles (clipRects / clipSize) and platform info; must be freed with freeInfo.
AwtRectangle -
{ x, y, width, height }used by bounds and clip.JAwtComponent / JAwtFrame - typed JObject aliases for
java.awt.Component/java.awt.Frame.
Types
The underlying open opaque type for JAwtComponent.
The underlying open opaque type for JAwtFrame.
Structure for a native rectangle.
Structure for a native rectangle.
Java version that corresponds to the new JAWT API.
Contains the underlying drawing information of a component.
Contains the underlying drawing information of a component.
Pointer to java.awt.Component.
Pointer to java.awt.Frame.
The underlying type for DrawingSurface.
The underlying type for DrawingSurface.
The underlying type for DrawingSurfaceInfo.
The underlying type for DrawingSurfaceInfo.
Properties
Bounding rectangle of the drawing surface.
Clip rectangle C array.
Clip rectangle list.
Number of rectangles in the clip.
DDB handle.
This HDC should always be used instead of the HDC returned from BeginPaint() or any calls to GetDC().
Native window handle.
DIB handle.
Cached pointer to the underlying drawing surface.
Cached reference to the target object.
Version of AWT.
Functions
Creates a java.awt.Frame placed in a native container. Container is referenced by the native platform handle:
Free the drawing surface allocated in getDrawingSurface.
Free the drawing surface info.
Get the AWT native structure.
Returns a pixel value from a set of RGB values. This is useful for paletted color (256 color) modes.
Returns a reference to a java.awt.Component from a native platform handle:
Return a drawing surface from a target JAwtComponent. This value may be cached.
fun Awt.synthesizeWindowActivation(embeddedFrame: JAwtFrame, doActivate: Boolean)
Synthesize a native message to activate or deactivate an EmbeddedFrame window. If doActivate is true activates the window, otherwise, deactivates the window.
inline fun <T> Awt.useDrawingSurface(target: JAwtComponent, block: (DrawingSurface) -> T): T
Gets a DrawingSurface from a target JAwtComponent and executes block with it. Then safely release the surface.
inline fun <T> Awt.useDrawingSurfaceInfo(target: JAwtComponent, block: DrawingSurface.(DrawingSurfaceInfo) -> T): T
Alias for stacking Awt.useDrawingSurface, DrawingSurface.locking and DrawingSurface.useInfo.
Gets a DrawingSurfaceInfo and executes block, then release the surface info.