Package icyllis.modernui.core.awt
Class AWT
java.lang.Object
icyllis.modernui.core.awt.AWT
- All Implemented Interfaces:
AutoCloseable
Creates and manages the native AWT object with ease.
Example 1:
Component c = ...;
try(AWT awt = new AWT(c)) {
long pPlatformInfo = awt.getPlatformInfo();
// ... do something with the platform info
}
// The AWT object is automatically freed!
Example 2:
Component c = ...;
AWT awt = new AWT(c);
long pPlatformInfo = awt.getPlatformInfo();
// ... do something with the platform info
awt.close();
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Frees memory and unlocks the drawing surface.org.lwjgl.system.jawt.JAWTDrawingSurfaceInfo
Gets the underlying platform drawing surface struct.long
Returns a pointer to a platform-specific struct with platform-specific information.static boolean
Checks if the platform is supported.
-
Constructor Details
-
AWT
Initializes native window handlers from the desired AWT component. The component MUST be aComponent
, but should be a canvas or window for native rendering.If not used in a try-with-resources block, call
close()
when done.- Parameters:
component
- a component to render onto- Throws:
AWTException
- Fails for one of the provided reasons:- if the JAWT library failed to initialize;
- if the drawing surface could not be retrieved;
- if JAWT failed to lock the drawing surface;
- or if JAWT failed to get information about the drawing surface;
-
-
Method Details
-
isPlatformSupported
public static boolean isPlatformSupported()Checks if the platform is supported. The OS version is not checked, but the architecture (e.g. 32 or 64 bit) is.- Returns:
- true if the platform is supported
-
getPlatformInfo
public long getPlatformInfo()Returns a pointer to a platform-specific struct with platform-specific information.The pointer can be safely used as a
JAWTWin32DrawingSurfaceInfo
orJAWTX11DrawingSurfaceInfo
struct, or--if on MacOS-- a pointer to anNSObject
.On win32 or X11 platforms, this can easily be created in Java via LWJGL's
#create(long)
method.- Returns:
- pointer to platform-specific data
-
getDrawingSurfaceInfo
public org.lwjgl.system.jawt.JAWTDrawingSurfaceInfo getDrawingSurfaceInfo()Gets the underlying platform drawing surface struct.- Returns:
- the drawing surface
-
close
public void close()Frees memory and unlocks the drawing surface.- Specified by:
close
in interfaceAutoCloseable
-