APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.badlogic.gdx.backends.lwjgl

public Class LwjglAWTCanvas

extends Object
implements Application
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.Application
Imports
java.awt.Canvas, .Color, .Component, .Cursor, .Dimension, .EventQueue, .Frame, .GraphicsEnvironment, .Rectangle, .Toolkit, java.awt.event.PaintEvent, java.util.HashMap, .Map, javax.swing.SwingUtilities, com.badlogic.gdx.ApplicationLogger, .Application, .ApplicationListener, .Audio, .Files, .Gdx, .Graphics, .Input, .LifecycleListener, .Net, .Preferences, org.lwjgl.LWJGLException, org.lwjgl.opengl.AWTGLCanvas, .Display, .PixelFormat, com.badlogic.gdx.backends.lwjgl.audio.OpenALLwjglAudio, com.badlogic.gdx.utils.Array, .Clipboard

An OpenGL surface on an AWT Canvas, allowing OpenGL to be embedded in a Swing application. This uses AWTGLCanvas, which allows multiple LwjglAWTCanvas to be used in a single application. All OpenGL calls are done on the EDT. Note that you may need to call stop() or a Swing application may deadlock on System.exit due to how LWJGL and/or Swing deal with shutdown hooks.
Author
Nathan Sweet

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
pack-priv ApplicationLogger
pack-priv OpenALLwjglAudio
pack-priv AWTGLCanvas
pack-priv Cursor
pack-priv final Array<Runnable>
pack-priv LwjglFiles
pack-priv LwjglGraphics
pack-priv LwjglAWTInput
pack-priv static int
pack-priv int
pack-priv int
pack-priv final Array<LifecycleListener>
pack-priv final ApplicationListener
pack-priv int
pack-priv final String
pack-priv LwjglNet
pack-priv Map<String, Preferences>
pack-priv final Array<Runnable>
pack-priv boolean

Constructor Summary

AccessConstructor and Description
public
public
LwjglAWTCanvas(ApplicationListener listener, LwjglAWTCanvas sharedContextCanvas)

public
public

Method Summary

Modifier and TypeMethod and Description
public void
pack-priv void
public void
debug(String tag, String message)

Implements com.badlogic.gdx.Application.debug.

Logs a debug message to the console or logcat

public void
debug(String tag, String message, Throwable exception)

Implements com.badlogic.gdx.Application.debug.

Logs a debug message to the console or logcat

public void
error(String tag, String message)

Implements com.badlogic.gdx.Application.error.

Logs an error message to the console or logcat

public void
error(String tag, String message, Throwable exception)

Implements com.badlogic.gdx.Application.error.

Logs an error message to the console or logcat

protected void
public boolean
public void
exit()

Implements com.badlogic.gdx.Application.exit.

Schedule an exit from the application.

public ApplicationListener
public ApplicationLogger
public Audio
public Canvas
public Clipboard
public Files
protected int
public Graphics
public Input
public long
public int
getLogLevel()

Implements com.badlogic.gdx.Application.getLogLevel.

Gets the log level.

public long
public Net
public Preferences
getPreferences(String name)

Implements com.badlogic.gdx.Application.getPreferences.

Returns the Preferences instance of this Application.

public Application.ApplicationType
public int
public boolean
isActive()

Returns true when the frame containing the canvas is the foreground window.

public boolean
isCurrent()

Test whether the canvas' context is current.

public void
log(String tag, String message)

Implements com.badlogic.gdx.Application.log.

Logs a message to the console or logcat

public void
log(String tag, String message, Throwable exception)

Implements com.badlogic.gdx.Application.log.

Logs a message to the console or logcat

public void
makeCurrent()

Make the canvas' context current.

public void
postRunnable(Runnable runnable)

Implements com.badlogic.gdx.Application.postRunnable.

Posts a Runnable on the main loop thread.

public void
pack-priv void
render(boolean shouldRender)

protected void
resize(int width, int height)

Called when the canvas size changes.

public void
setApplicationLogger(ApplicationLogger applicationLogger)

Implements com.badlogic.gdx.Application.setApplicationLogger.

Sets the current Application logger.

public void
setCursor(Cursor
May be null.
cursor
)

protected void
setDisplayMode(int width, int height)

pack-priv void
public void
setLogLevel(int logLevel)

Implements com.badlogic.gdx.Application.setLogLevel.

Sets the log level.

protected void
protected void
start()

Called after ApplicationListener create and resize, but before the game loop iteration.

public void
stop()

protected void
stopped()

Called when the game loop has stopped.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

applicationLoggerback to summary
pack-priv ApplicationLogger applicationLogger
audioback to summary
pack-priv OpenALLwjglAudio audio
canvasback to summary
pack-priv AWTGLCanvas canvas
cursorback to summary
pack-priv Cursor cursor
executedRunnablesback to summary
pack-priv final Array<Runnable> executedRunnables
filesback to summary
pack-priv LwjglFiles files
graphicsback to summary
pack-priv LwjglGraphics graphics
inputback to summary
pack-priv LwjglAWTInput input
instanceCountback to summary
pack-priv static int instanceCount
lastHeightback to summary
pack-priv int lastHeight
lastWidthback to summary
pack-priv int lastWidth
lifecycleListenersback to summary
pack-priv final Array<LifecycleListener> lifecycleListeners
listenerback to summary
pack-priv final ApplicationListener listener
logLevelback to summary
pack-priv int logLevel
logTagback to summary
pack-priv final String logTag
netback to summary
pack-priv LwjglNet net
preferencesback to summary
pack-priv Map<String, Preferences> preferences
runnablesback to summary
pack-priv final Array<Runnable> runnables
runningback to summary
pack-priv boolean running

Constructor Detail

LwjglAWTCanvasback to summary
public LwjglAWTCanvas(ApplicationListener listener)
LwjglAWTCanvasback to summary
public LwjglAWTCanvas(ApplicationListener listener, LwjglAWTCanvas sharedContextCanvas)
LwjglAWTCanvasback to summary
public LwjglAWTCanvas(ApplicationListener listener, LwjglApplicationConfiguration config)
LwjglAWTCanvasback to summary
public LwjglAWTCanvas(ApplicationListener listener, LwjglApplicationConfiguration config, LwjglAWTCanvas sharedContextCanvas)

Method Detail

addLifecycleListenerback to summary
public void addLifecycleListener(LifecycleListener listener)

Implements com.badlogic.gdx.Application.addLifecycleListener.

Doc from com.badlogic.gdx.Application.addLifecycleListener.

Adds a new LifecycleListener to the application. This can be used by extensions to hook into the lifecycle more easily. The ApplicationListener methods are sufficient for application level development.

Annotations
@Override
createback to summary
pack-priv void create()
debugback to summary
public void debug(String tag, String message)

Implements com.badlogic.gdx.Application.debug.

Doc from com.badlogic.gdx.Application.debug.

Logs a debug message to the console or logcat

Annotations
@Override
debugback to summary
public void debug(String tag, String message, Throwable exception)

Implements com.badlogic.gdx.Application.debug.

Doc from com.badlogic.gdx.Application.debug.

Logs a debug message to the console or logcat

Annotations
@Override
errorback to summary
public void error(String tag, String message)

Implements com.badlogic.gdx.Application.error.

Doc from com.badlogic.gdx.Application.error.

Logs an error message to the console or logcat

Annotations
@Override
errorback to summary
public void error(String tag, String message, Throwable exception)

Implements com.badlogic.gdx.Application.error.

Doc from com.badlogic.gdx.Application.error.

Logs an error message to the console or logcat

Annotations
@Override
exceptionback to summary
protected void exception(Throwable ex)
executeRunnablesback to summary
public boolean executeRunnables()
exitback to summary
public void exit()

Implements com.badlogic.gdx.Application.exit.

Doc from com.badlogic.gdx.Application.exit.

Schedule an exit from the application. On android, this will cause a call to pause() and dispose() some time in the future, it will not immediately finish your application. On iOS this should be avoided in production as it breaks Apples guidelines

Annotations
@Override
getApplicationListenerback to summary
public ApplicationListener getApplicationListener()

Implements com.badlogic.gdx.Application.getApplicationListener.

Annotations
@Override
getApplicationLoggerback to summary
public ApplicationLogger getApplicationLogger()

Implements com.badlogic.gdx.Application.getApplicationLogger.

Annotations
@Override
getAudioback to summary
public Audio getAudio()

Implements com.badlogic.gdx.Application.getAudio.

Annotations
@Override
getCanvasback to summary
public Canvas getCanvas()
getClipboardback to summary
public Clipboard getClipboard()

Implements com.badlogic.gdx.Application.getClipboard.

Annotations
@Override
getFilesback to summary
public Files getFiles()

Implements com.badlogic.gdx.Application.getFiles.

Annotations
@Override
getFrameRateback to summary
protected int getFrameRate()
getGraphicsback to summary
public Graphics getGraphics()

Implements com.badlogic.gdx.Application.getGraphics.

Annotations
@Override
getInputback to summary
public Input getInput()

Implements com.badlogic.gdx.Application.getInput.

Annotations
@Override
getJavaHeapback to summary
public long getJavaHeap()

Implements com.badlogic.gdx.Application.getJavaHeap.

Annotations
@Override
getLogLevelback to summary
public int getLogLevel()

Implements com.badlogic.gdx.Application.getLogLevel.

Doc from com.badlogic.gdx.Application.getLogLevel.

Gets the log level.

Annotations
@Override
getNativeHeapback to summary
public long getNativeHeap()

Implements com.badlogic.gdx.Application.getNativeHeap.

Annotations
@Override
getNetback to summary
public Net getNet()

Implements com.badlogic.gdx.Application.getNet.

Annotations
@Override
getPreferencesback to summary
public Preferences getPreferences(String name)

Implements com.badlogic.gdx.Application.getPreferences.

Doc from com.badlogic.gdx.Application.getPreferences.

Returns the Preferences instance of this Application. It can be used to store application settings across runs.

Annotations
@Override
getTypeback to summary
public Application.ApplicationType getType()

Implements com.badlogic.gdx.Application.getType.

Annotations
@Override
getVersionback to summary
public int getVersion()

Implements com.badlogic.gdx.Application.getVersion.

Annotations
@Override
isActiveback to summary
public boolean isActive()

Returns true when the frame containing the canvas is the foreground window.

isCurrentback to summary
public boolean isCurrent()

Test whether the canvas' context is current.

logback to summary
public void log(String tag, String message)

Implements com.badlogic.gdx.Application.log.

Doc from com.badlogic.gdx.Application.log.

Logs a message to the console or logcat

Annotations
@Override
logback to summary
public void log(String tag, String message, Throwable exception)

Implements com.badlogic.gdx.Application.log.

Doc from com.badlogic.gdx.Application.log.

Logs a message to the console or logcat

Annotations
@Override
makeCurrentback to summary
public void makeCurrent()

Make the canvas' context current. It is highly recommended that the context is only made current inside the AWT thread (for example in an overridden paintGL()).

postRunnableback to summary
public void postRunnable(Runnable runnable)

Implements com.badlogic.gdx.Application.postRunnable.

Doc from com.badlogic.gdx.Application.postRunnable.

Posts a Runnable on the main loop thread. In a multi-window application, the Gdx#graphics and Gdx#input values may be unpredictable at the time the Runnable is executed. If graphics or input are needed, they can be copied to a variable to be used in the Runnable. For example:

final Graphics graphics = Gdx.graphics;

Annotations
@Override
removeLifecycleListenerback to summary
public void removeLifecycleListener(LifecycleListener listener)

Implements com.badlogic.gdx.Application.removeLifecycleListener.

Doc from com.badlogic.gdx.Application.removeLifecycleListener.

Removes the LifecycleListener.

Annotations
@Override
renderback to summary
pack-priv void render(boolean shouldRender) throws LWJGLException
resizeback to summary
protected void resize(int width, int height)

Called when the canvas size changes.

setApplicationLoggerback to summary
public void setApplicationLogger(ApplicationLogger applicationLogger)

Implements com.badlogic.gdx.Application.setApplicationLogger.

Doc from com.badlogic.gdx.Application.setApplicationLogger.

Sets the current Application logger. Calls to log(String, String) are delegated to this ApplicationLogger

Annotations
@Override
setCursorback to summary
public void setCursor(Cursor cursor)
Parameters
cursor:Cursor

May be null.

setDisplayModeback to summary
protected void setDisplayMode(int width, int height)
setGlobalsback to summary
pack-priv void setGlobals()
setLogLevelback to summary
public void setLogLevel(int logLevel)

Implements com.badlogic.gdx.Application.setLogLevel.

Doc from com.badlogic.gdx.Application.setLogLevel.

Sets the log level. LOG_NONE will mute all log output. LOG_ERROR will only let error messages through. LOG_INFO will let all non-debug messages through, and LOG_DEBUG will let all messages through.

Annotations
@Override
setTitleback to summary
protected void setTitle(String title)
startback to summary
protected void start()

Called after ApplicationListener create and resize, but before the game loop iteration.

stopback to summary
public void stop()
stoppedback to summary
protected void stopped()

Called when the game loop has stopped.

com.badlogic.gdx.backends.lwjgl back to summary

public Class LwjglAWTCanvas.NonSystemPaint

extends PaintEvent
Class Inheritance

Field Summary

Inherited from java.awt.event.PaintEvent:
PAINTPAINT_FIRSTPAINT_LASTUPDATE

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from java.awt.event.PaintEvent:
getUpdateRectparamStringsetUpdateRect

Constructor Detail

NonSystemPaintback to summary
public NonSystemPaint(AWTGLCanvas canvas)