29package com.jogamp.opengl.test.junit.newt;
32import org.junit.FixMethodOrder;
33import org.junit.runners.MethodSorters;
34import org.junit.Assert;
36import java.lang.reflect.InvocationTargetException;
38import javax.swing.JFrame;
39import javax.swing.SwingUtilities;
40import javax.swing.WindowConstants;
41import com.jogamp.nativewindow.NativeWindow;
42import com.jogamp.nativewindow.util.Point;
43import com.jogamp.opengl.GLCapabilities;
44import com.jogamp.opengl.GLProfile;
46import com.jogamp.newt.Window;
47import com.jogamp.newt.awt.NewtCanvasAWT;
48import com.jogamp.newt.opengl.GLWindow;
49import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
50import com.jogamp.opengl.test.junit.util.NewtTestUtil;
51import com.jogamp.opengl.test.junit.util.TestUtil;
52import com.jogamp.opengl.test.junit.util.UITestCase;
54@FixMethodOrder(MethodSorters.NAME_ASCENDING)
61 @SuppressWarnings(
"serial")
63 public MyCanvas(
final Window window) {
67 public void addNotify() {
68 System.err.println(
"MyCanvas START add: "+Thread.currentThread()+
", holds AWTTreeLock: "+Thread.holdsLock(
this.getTreeLock()));
70 System.err.println(
"MyCanvas END add: "+Thread.currentThread()+
", holds AWTTreeLock: "+Thread.holdsLock(
this.getTreeLock()));
73 public void removeNotify() {
74 System.err.println(
"MyCanvas START remove: "+Thread.currentThread()+
", holds AWTTreeLock: "+Thread.holdsLock(
this.getTreeLock()));
80 System.err.println(
"MyCanvas On NEWT-EDT From AWT-EDT: "+Thread.currentThread()+
81 ", holds AWTTreeLock: "+Thread.holdsLock(MyCanvas.this.getTreeLock()));
87 System.err.println(
"MyCanvas On NEWT-EDT: position: "+p);
89 System.err.println(
"MyCanvas On NEWT-EDT: position n/a, null NativeWindow");
93 System.err.println(
"MyCanvas passed critical: "+Thread.currentThread()+
", holds AWTTreeLock: "+Thread.holdsLock(this.getTreeLock()));
97 System.err.println(
"MyCanvas END remove: "+Thread.currentThread()+
", holds AWTTreeLock: "+Thread.holdsLock(this.getTreeLock()));
104 newtCanvas =
new MyCanvas(newtWindow);
106 SwingUtilities.invokeAndWait(
new Runnable() {
108 frame =
new JFrame(
"NEWT Close Test");
109 frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
110 frame.getContentPane().add(newtCanvas);
112 frame.setSize(800, 600);
113 frame.setVisible(
true);
124 public static void main(
final String[] args) {
126 org.junit.runner.JUnitCore.
main(tstname);
AWT Canvas containing a NEWT Window using native parenting.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final void runOnEDTIfAvail(final boolean wait, final Runnable task)
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
static GLProfile getDefault(final AbstractGraphicsDevice device)
Returns a default GLProfile object, reflecting the best for the running platform.
static void main(final String[] args)
static TestUtil.WindowClosingListener addClosingListener(final java.awt.Window win)
static boolean closeWindow(final java.awt.Window win, final boolean willClose, final TestUtil.WindowClosingListener closingListener, final Runnable waitAction)
Programmatically issue windowClosing on AWT or NEWT.
static boolean waitForVisible(final java.awt.Component comp, final boolean visible, final Runnable waitAction)
static boolean waitForRealized(final Screen screen, final boolean realized, final Runnable waitAction)
Extend the NativeSurface interface with windowing information such as window-handle,...
Point getLocationOnScreen(Point point)
Returns the window's top-left client-area position in the screen.
Specifying NEWT's Window functionality: