JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
com.jogamp.newt.event.awt.AWTAdapter Class Referenceabstract

Convenient adapter forwarding AWT events to NEWT via the event listener model. More...

Inheritance diagram for com.jogamp.newt.event.awt.AWTAdapter:
Collaboration diagram for com.jogamp.newt.event.awt.AWTAdapter:

Classes

enum  EventProcRes
 Return value for event processing.
 

Public Member Functions

 AWTAdapter ()
 
synchronized AWTAdapter setDownstream (final com.jogamp.newt.Window downstream) throws IllegalStateException
 Setup a pipeline adapter, AWT EventListener. More...
 
synchronized AWTAdapter clear ()
 Removes all references, downstream and NEWT-EventListener. More...
 
final synchronized void setConsumeAWTEvent (final boolean v)
 
final synchronized NativeSurfaceHolder getNativeSurfaceHolder ()
 Returns the NativeSurfaceHolder acting as downstream, NEWT window proxy or as an NativeSurfaceHolder proxy. More...
 
final synchronized com.jogamp.newt.Window getNewtWindow ()
 Returns the NEWT Window acting as downstream or as a NEWT window proxy. More...
 
final synchronized com.jogamp.newt.event.NEWTEventListener getNewtEventListener ()
 Returns the NEWT event-listener if instance is used as an NativeSurfaceHolder proxy or NEWT window proxy, otherwise method returns null. More...
 
abstract AWTAdapter addTo (java.awt.Component awtComponent)
 Due to the fact that some NEWT com.jogamp.newt.event.NEWTEventListener are mapped to more than one java.util.EventListener, this method is for your convenience to use this Adapter as a listener for all types. More...
 
abstract AWTAdapter removeFrom (java.awt.Component awtComponent)
 

Static Public Attributes

static final boolean DEBUG_IMPLEMENTATION = Debug.debug("Window")
 

Protected Member Functions

 AWTAdapter (final com.jogamp.newt.event.NEWTEventListener newtListener, final NativeSurfaceHolder nsProxy)
 Create a proxy adapter, wrapping around an NEWT EventListener, exposed as an AWT EventListener,
where the given NativeSurfaceHolder impersonates the event's source. More...
 
 AWTAdapter (final com.jogamp.newt.event.NEWTEventListener newtListener, final com.jogamp.newt.Window newtProxy)
 Create a proxy adapter, wrapping around an NEWT EventListener, exposed as an AWT EventListener,
where the given NEWT Window, a NativeSurfaceHolder, impersonates the event's source. More...
 
 AWTAdapter (final com.jogamp.newt.Window downstream) throws IllegalStateException
 Create a pipeline adapter, AWT EventListener. More...
 

Protected Attributes

boolean isSetup
 

Detailed Description

Convenient adapter forwarding AWT events to NEWT via the event listener model.


You may attach an instance of this adapter to an AWT Component. When an event happens, it is converted to a NEWT event and the given NEWT listener is being called.

This adapter fullfills three use cases. First as a plain utility to write code AWT agnostic, ie write an com.jogamp.opengl.GLEvenListener and some appropriate NEWT com.jogamp.newt.event.NEWTEventListener.

Attach the com.jogamp.opengl.GLEvenListener to a NEWT com.jogamp.opengl.GLAutoDrawable, e.g. com.jogamp.newt.opengl.GLWindow,
or to an AWT com.jogamp.opengl.GLAutoDrawable, e.g. com.jogamp.opengl.awt.GLCanvas.

Attach the NEWT com.jogamp.newt.event.NEWTEventListener to a NEWT component, e.g. com.jogamp.newt.Window,
or to an AWT component, e.g. java.awt.Component.

Common:

 // your demo/render code
 com.jogamp.opengl.GLEvenListener demo1 = new com.jogamp.opengl.GLEvenListener() { ... } ;

 // your AWT agnostic NEWT mouse listener code
 com.jogamp.newt.event.MouseListener mouseListener = new com.jogamp.newt.event.MouseAdapter() { ... } ;

Default NEWT use case, without using the AWTAdapter:

 // the NEWT GLAutoDrawable and Window
 GLWindow glWindow = GLWindow.create();

 // attach the renderer demo1
 glWindow.addGLEventListener(demo1);

 // attach the NEWT mouse event listener to glWindow
 glWindow.addMouseListener(mouseListener);

AWT use case, AWTAdapter used as an AWT event translator and forwarder to your NEWT listener:

 // the AWT GLAutoDrawable and Canvas
 GLCanvas glCanvas = new GLCanvas();

 // attach the renderer demo1
 glCanvas.addGLEventListener(demo1);

 // attach the AWTMouseAdapter to glCanvas, which translates and forwards events to the NEWT mouseListener
 new AWTMouseAdapter(mouseListener).addTo(glCanvas);

Previous code in detail:

 AWTMouseAdapter mouseAdapter = new AWTMouseAdapter(mouseListener);
 glCanvas.addMouseListener(mouseAdapter);
 glCanvas.addMouseMotionListener(mouseAdapter);

Second use case is just a litte variation of the previous use case, where we pass a NEWT Window
to be used as the source of the event.

 com.jogamp.newt.event.MouseListener mouseListener = new com.jogamp.newt.event.MouseAdapter() { ... } ;
Component comp = ... ; // the AWT component
GLWindow glWindow = GLWindow.create(); // the NEWT component

new AWTMouseAdapter(mouseListener, glWindow).addTo(comp);

Last but not least, the AWTAdapter maybe used as a general AWT event forwarder to NEWT.

 com.jogamp.newt.event.MouseListener mouseListener = new com.jogamp.newt.event.MouseAdapter() { ... } ;
Component comp = ... ; // the AWT component
GLWindow glWindow = GLWindow.create(); // the NEWT component
glWindow.addMouseListener(mouseListener); // add the custom EventListener to the NEWT component

new AWTMouseAdapter(glWindow).addTo(comp); // forward all AWT events to glWindow, as NEWT events
See also
#attachTo

Definition at line 116 of file AWTAdapter.java.

Constructor & Destructor Documentation

◆ AWTAdapter() [1/4]

com.jogamp.newt.event.awt.AWTAdapter.AWTAdapter ( final com.jogamp.newt.event.NEWTEventListener  newtListener,
final NativeSurfaceHolder  nsProxy 
)
protected

Create a proxy adapter, wrapping around an NEWT EventListener, exposed as an AWT EventListener,
where the given NativeSurfaceHolder impersonates the event's source.

The NEWT EventListener will be called when an event happens.

Definition at line 131 of file AWTAdapter.java.

◆ AWTAdapter() [2/4]

com.jogamp.newt.event.awt.AWTAdapter.AWTAdapter ( final com.jogamp.newt.event.NEWTEventListener  newtListener,
final com.jogamp.newt.Window  newtProxy 
)
protected

Create a proxy adapter, wrapping around an NEWT EventListener, exposed as an AWT EventListener,
where the given NEWT Window, a NativeSurfaceHolder, impersonates the event's source.

The NEWT EventListener will be called when an event happens.

Definition at line 150 of file AWTAdapter.java.

◆ AWTAdapter() [3/4]

com.jogamp.newt.event.awt.AWTAdapter.AWTAdapter ( final com.jogamp.newt.Window  downstream) throws IllegalStateException
protected

Create a pipeline adapter, AWT EventListener.


Once attached to an AWT component, it sends the converted AWT events to the NEWT downstream window.
This is only supported with EDT enabled!

Exceptions
IllegalStateExceptionif EDT is not enabled

Definition at line 170 of file AWTAdapter.java.

Here is the call graph for this function:

◆ AWTAdapter() [4/4]

com.jogamp.newt.event.awt.AWTAdapter.AWTAdapter ( )

Definition at line 175 of file AWTAdapter.java.

Here is the call graph for this function:

Member Function Documentation

◆ addTo()

abstract AWTAdapter com.jogamp.newt.event.awt.AWTAdapter.addTo ( java.awt.Component  awtComponent)
abstract

Due to the fact that some NEWT com.jogamp.newt.event.NEWTEventListener are mapped to more than one java.util.EventListener, this method is for your convenience to use this Adapter as a listener for all types.


E.g. com.jogamp.newt.event.MouseListener is mapped to java.awt.event.MouseListener and java.awt.event.MouseMotionListener.

Reimplemented in com.jogamp.newt.event.awt.AWTKeyAdapter, com.jogamp.newt.event.awt.AWTMouseAdapter, and com.jogamp.newt.event.awt.AWTWindowAdapter.

Here is the caller graph for this function:

◆ clear()

synchronized AWTAdapter com.jogamp.newt.event.awt.AWTAdapter.clear ( )

Removes all references, downstream and NEWT-EventListener.

Also sets the internal setup flag and setConsumeAWTEvent(boolean) to false.

Definition at line 206 of file AWTAdapter.java.

Here is the caller graph for this function:

◆ getNativeSurfaceHolder()

final synchronized NativeSurfaceHolder com.jogamp.newt.event.awt.AWTAdapter.getNativeSurfaceHolder ( )

Returns the NativeSurfaceHolder acting as downstream, NEWT window proxy or as an NativeSurfaceHolder proxy.

Returned value is never null.

Definition at line 227 of file AWTAdapter.java.

◆ getNewtEventListener()

final synchronized com.jogamp.newt.event.NEWTEventListener com.jogamp.newt.event.awt.AWTAdapter.getNewtEventListener ( )

Returns the NEWT event-listener if instance is used as an NativeSurfaceHolder proxy or NEWT window proxy, otherwise method returns null.

Definition at line 249 of file AWTAdapter.java.

◆ getNewtWindow()

final synchronized com.jogamp.newt.Window com.jogamp.newt.event.awt.AWTAdapter.getNewtWindow ( )

Returns the NEWT Window acting as downstream or as a NEWT window proxy.

Returned value maybe null if instance is used to be a NativeSurfaceHolder proxy.

Definition at line 239 of file AWTAdapter.java.

◆ removeFrom()

abstract AWTAdapter com.jogamp.newt.event.awt.AWTAdapter.removeFrom ( java.awt.Component  awtComponent)
abstract

◆ setConsumeAWTEvent()

final synchronized void com.jogamp.newt.event.awt.AWTAdapter.setConsumeAWTEvent ( final boolean  v)

Definition at line 215 of file AWTAdapter.java.

◆ setDownstream()

synchronized AWTAdapter com.jogamp.newt.event.awt.AWTAdapter.setDownstream ( final com.jogamp.newt.Window  downstream) throws IllegalStateException

Setup a pipeline adapter, AWT EventListener.


Once attached to an AWT component, it sends the converted AWT events to the NEWT downstream window.
This is only supported with EDT enabled!

Exceptions
IllegalStateExceptionif EDT is not enabled

Definition at line 186 of file AWTAdapter.java.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ DEBUG_IMPLEMENTATION

final boolean com.jogamp.newt.event.awt.AWTAdapter.DEBUG_IMPLEMENTATION = Debug.debug("Window")
static

Definition at line 118 of file AWTAdapter.java.

◆ isSetup

boolean com.jogamp.newt.event.awt.AWTAdapter.isSetup
protected

Definition at line 124 of file AWTAdapter.java.


The documentation for this class was generated from the following file: