|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jogamp.newt.event.awt.AWTAdapter
public abstract class AWTAdapter
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 happen,
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 javax.media.opengl.GLEvenListener
and some appropriate NEWT NEWTEventListener
.
Attach the javax.media.opengl.GLEvenListener
to a NEWT GLAutoDrawable
, e.g. GLWindow
,
or to an AWT GLAutoDrawable
, e.g. GLCanvas
.
Attach the NEWT NEWTEventListener
to a NEWT component, e.g. Window
,
or to an AWT component, e.g. Component
.
Common:
javax.media.opengl.GLEvenListener demo1 = new javax.media.opengl.GLEvenListener() { ... } ;
com.jogamp.newt.event.MouseListener mouseListener = new com.jogamp.newt.event.MouseAdapter() { ... } ;
NEWT Usage:
GLWindow glWindow = GLWindow.create();
glWindow.addGLEventListener(demo1);
glWindow.addMouseListener(mouseListener);
AWT Usage:
GLCanvas glCanvas = new GLCanvas();
glCanvas.addGLEventListener(demo1);
new AWTMouseAdapter(mouseListener).addTo(glCanvas);
AWT Usage (previous form in detail):
AWTMouseAdapter mouseAdapter = new AWTMouseAdapter(mouseListener);
glCanvas.addMouseListener(mouseAdapter);
glCanvas.addMouseMotionListener(mouseAdapter);
Second is just a litte variation, where we pass a NEWT Window
to impersonate 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);
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
#attachTo
Constructor Summary | |
---|---|
AWTAdapter(NEWTEventListener newtListener)
Simply wrap aroung a NEWT EventListener, exposed as an AWT EventListener. The NEWT EventListener will be called when an event happens. |
|
AWTAdapter(NEWTEventListener newtListener,
Window newtProxy)
Wrap aroung a NEWT EventListener, exposed as an AWT EventListener, where the given NEWT Window impersonates as the event's source. |
|
AWTAdapter(Window downstream)
Create a pipeline adapter, AWT EventListener. Once attached to an AWT component, it sends the converted AWT events to the NEWT downstream window. |
Method Summary | |
---|---|
abstract AWTAdapter |
addTo(Component awtComponent)
Due to the fact that some NEWT NEWTEventListener
are mapped to more than one EventListener ,
this method is for your convenience to use this Adapter as a listener for all types.E.g. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AWTAdapter(NEWTEventListener newtListener)
public AWTAdapter(NEWTEventListener newtListener, Window newtProxy)
public AWTAdapter(Window downstream)
Method Detail |
---|
public abstract AWTAdapter addTo(Component awtComponent)
NEWTEventListener
are mapped to more than one EventListener
,
this method is for your convenience to use this Adapter as a listener for all types.MouseListener
is mapped to MouseListener
and MouseMotionListener
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |