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:

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

HelperRole
withAwtgetAwt + throw if the VM does not expose JAWT
Awt.lockinglock / unlock the entire AWT (since 1.4)
Awt.useDrawingSurfacegetDrawingSurface + freeDrawingSurface
DrawingSurface.lockinglock + unlock; throws on JAWT.LOCK_ERROR
DrawingSurface.useInfogetInfo + freeInfo
Awt.useDrawingSurfaceInfosurface + 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.Frame inside a native parent (HWND / Drawable / NSWindow).

  • Awt.setBounds - move/resize that embedded frame relative to the native parent (Component.setBounds alone 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:

PlatformHandle
WindowsHWND
LinuxX11 Drawable
macOSNSWindow

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 - CALayer of the surface / window

Types

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:

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

HelperRole
withAwtgetAwt + throw if the VM does not expose JAWT
Awt.lockinglock / unlock the entire AWT (since 1.4)
Awt.useDrawingSurfacegetDrawingSurface + freeDrawingSurface
DrawingSurface.lockinglock + unlock; throws on JAWT.LOCK_ERROR
DrawingSurface.useInfogetInfo + freeInfo
Awt.useDrawingSurfaceInfosurface + 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.Frame inside a native parent (HWND / Drawable / NSWindow).

  • Awt.setBounds - move/resize that embedded frame relative to the native parent (Component.setBounds alone 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:

PlatformHandle
WindowsHWND
LinuxX11 Drawable
macOSNSWindow

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):

macOS (macosMain):

  • layer / windowLayer - CALayer of the surface / window

Types

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:

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

HelperRole
withAwtgetAwt + throw if the VM does not expose JAWT
Awt.lockinglock / unlock the entire AWT (since 1.4)
Awt.useDrawingSurfacegetDrawingSurface + freeDrawingSurface
DrawingSurface.lockinglock + unlock; throws on JAWT.LOCK_ERROR
DrawingSurface.useInfogetInfo + freeInfo
Awt.useDrawingSurfaceInfosurface + 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.Frame inside a native parent (HWND / Drawable / NSWindow).

  • Awt.setBounds - move/resize that embedded frame relative to the native parent (Component.setBounds alone 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:

PlatformHandle
WindowsHWND
LinuxX11 Drawable
macOSNSWindow

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):

Types

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:

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

HelperRole
withAwtgetAwt + throw if the VM does not expose JAWT
Awt.lockinglock / unlock the entire AWT (since 1.4)
Awt.useDrawingSurfacegetDrawingSurface + freeDrawingSurface
DrawingSurface.lockinglock + unlock; throws on JAWT.LOCK_ERROR
DrawingSurface.useInfogetInfo + freeInfo
Awt.useDrawingSurfaceInfosurface + 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.Frame inside a native parent (HWND / Drawable / NSWindow).

  • Awt.setBounds - move/resize that embedded frame relative to the native parent (Component.setBounds alone 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:

PlatformHandle
WindowsHWND
LinuxX11 Drawable
macOSNSWindow

Platform-specific DrawingSurfaceInfo members

Each desktop source set exposes the native structure members directly on DrawingSurfaceInfo - no platformInfo cast:

Windows (mingwMain):

Linux (linuxMain):

  • drawable, display, visualID, colormapID, depth

  • GetAWTColor - RGB → pixel for paletted modes (since 1.4)

macOS (macosMain):

  • layer / windowLayer - CALayer of the surface / window

Types

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:

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

HelperRole
withAwtgetAwt + throw if the VM does not expose JAWT
Awt.lockinglock / unlock the entire AWT (since 1.4)
Awt.useDrawingSurfacegetDrawingSurface + freeDrawingSurface
DrawingSurface.lockinglock + unlock; throws on JAWT.LOCK_ERROR
DrawingSurface.useInfogetInfo + freeInfo
Awt.useDrawingSurfaceInfosurface + 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.Frame inside a native parent (HWND / Drawable / NSWindow).

  • Awt.setBounds - move/resize that embedded frame relative to the native parent (Component.setBounds alone 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:

PlatformHandle
WindowsHWND
LinuxX11 Drawable
macOSNSWindow

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 - CALayer of the surface / window

Types

Types

Link copied to clipboard
open class _jawtComponent(rawPtr: NativePtr) : _jobject

The underlying open opaque type for JAwtComponent.

Link copied to clipboard
open class _jawtFrame(rawPtr: NativePtr) : _jawtComponent

The underlying open opaque type for JAwtFrame.

Link copied to clipboard
typealias Awt = CPointer<Raw_Awt>

AWT native interface.

Link copied to clipboard
actual typealias AwtRectangle = jawt_Rectangle
typealias AwtRectangle = jawt_Rectangle

Structure for a native rectangle.

expect class AwtRectangle : CStructVar

Structure for a native rectangle.

Link copied to clipboard
typealias AwtVersion = Int

Java version that corresponds to the new JAWT API.

Link copied to clipboard

Contains the underlying drawing information of a component.

Link copied to clipboard

Contains the underlying drawing information of a component.

Link copied to clipboard
object JAWT

Functions and utilities to work with JAWT (Java Abstract Window Toolkit).

Link copied to clipboard

Pointer to java.awt.Component.

Link copied to clipboard

Pointer to java.awt.Frame.

Link copied to clipboard
actual typealias Raw_Awt = jawt
typealias Raw_Awt = jawt

The underlying type for Awt.

expect class Raw_Awt : CStructVar

The underlying type for Awt.

Link copied to clipboard
actual typealias Raw_DrawingSurface = jawt_DrawingSurface
typealias Raw_DrawingSurface = jawt_DrawingSurface

The underlying type for DrawingSurface.

The underlying type for DrawingSurface.

Link copied to clipboard
actual typealias Raw_DrawingSurfaceInfo = jawt_DrawingSurfaceInfo
typealias Raw_DrawingSurfaceInfo = jawt_DrawingSurfaceInfo

The underlying type for DrawingSurfaceInfo.

The underlying type for DrawingSurfaceInfo.

Properties

Link copied to clipboard

Bounding rectangle of the drawing surface.

Link copied to clipboard

Clip rectangle C array.

Link copied to clipboard

Clip rectangle list.

Link copied to clipboard

Number of rectangles in the clip.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Cached reference to the Java environment of the calling thread. If lock, unlock, getInfo or freeInfo are called from a different thread, this data member should be set before calling those functions.

Link copied to clipboard

DDB handle.

Link copied to clipboard

This HDC should always be used instead of the HDC returned from BeginPaint() or any calls to GetDC().

Link copied to clipboard
Link copied to clipboard

Native window handle.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Cached pointer to the underlying drawing surface.

Link copied to clipboard

Cached reference to the target object.

Link copied to clipboard

Version of AWT.

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
context(env: JniEnv)
fun Awt.createEmbeddedFrame(platformInfo: COpaquePointer): JAwtFrame?

Creates a java.awt.Frame placed in a native container. Container is referenced by the native platform handle:

Link copied to clipboard

Free the drawing surface allocated in getDrawingSurface.

Link copied to clipboard

Free the drawing surface info.

Link copied to clipboard
context(env: JniEnv, placement: NativePlacement)
fun getAwt(version: AwtVersion): Awt?

Get the AWT native structure.

Link copied to clipboard

Returns a pixel value from a set of RGB values. This is useful for paletted color (256 color) modes.

Link copied to clipboard
context(env: JniEnv)
fun Awt.getComponent(platformInfo: COpaquePointer): JAwtComponent?

Returns a reference to a java.awt.Component from a native platform handle:

Link copied to clipboard

Return a drawing surface from a target JAwtComponent. This value may be cached.

Link copied to clipboard

Get the drawing surface info. The value returned may be cached, but the values may change if additional calls to lock or unlock are made.

Link copied to clipboard
context(env: JniEnv)
fun Awt.lock()

Locks the entire AWT for synchronization purposes.

Lock the surface of the target component for native rendering. When finished drawing, the surface must be unlocked with unlock).

Link copied to clipboard
context(env: JniEnv)
inline fun <T> Awt.locking(block: () -> T): T

Locks the entire AWT, executes block and then release lock.

inline fun <T> DrawingSurface.locking(block: context(JniEnv) () -> T): T

Locks the surface and executes block, then release lock.

Link copied to clipboard
context(env: JniEnv)
fun Awt.setBounds(embeddedFrame: JAwtFrame, x: Int, y: Int, w: Int, h: Int)

Moves and resizes the embedded frame. The new location of the top-left corner is specified by x and y parameters relative to the native parent component. The new size is specified by width and height.

Link copied to clipboard
context(env: JniEnv)
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.

Link copied to clipboard
context(env: JniEnv)
fun Awt.unlock()

Unlocks the entire AWT for synchronization purposes.

Unlock the drawing surface of the target component for native rendering.

Link copied to clipboard
context(env: JniEnv)
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.

Link copied to clipboard
Link copied to clipboard
inline fun <T> DrawingSurface.useInfo(block: (DrawingSurfaceInfo) -> T): T

Gets a DrawingSurfaceInfo and executes block, then release the surface info.

Link copied to clipboard
context(env: JniEnv, placement: NativePlacement)
inline fun <T> withAwt(version: AwtVersion, block: (Awt) -> T): T

Receive Awt from JniEnv and executes block with it.