https://forum.jogamp.org/Newt-and-reparenting-preserving-the-native-window-handle-tp4031873p4031884.html
Hi Sven:
Thanks for the quick replies. My snippet is derived from TestParenting04AWT.java. I've added 4 lines marked with "// <<<<" to compare the window handle before and after reparenting.
Here's the output below. Do you think there's a way to write a snippet where a child window is moved to a different parent while preserving its own native handle on Windows?
Handle before reparenting: 21237418
Handle after reparenting: 21302954
protected void winHopFrame2Frame(final boolean detachFirst) throws InterruptedException, InvocationTargetException {
...
for(state=0; state<3; state++) {
Thread.sleep(durationPerTest);
switch(state) {
case 0:
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
// 1 -> 2
if(detachFirst) {
canvas1.setNEWTChild(null);
canvas2.setNEWTChild(null);
} else {
canvas2.setNEWTChild(null); // free g2 of w2
}
long handle1 = glWindow2.getWindowHandle(); // <<<<<
canvas1.setNEWTChild(glWindow2); // put g2 -> w1. free g1 of w1
canvas2.setNEWTChild(glWindow1); // put g1 -> w2
frame1.invalidate();
frame2.invalidate();
frame1.validate();
frame2.validate();
long handle2 = glWindow2.getWindowHandle(); // <<<<<
System.out.println("Handle before reparenting: "+handle1); // <<<<<
System.out.println("Handle after reparenting: "+handle2); // <<<<<