From a27af8dc7120eac0cf84a777e7a7d82dae548c01 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 3 Apr 2013 17:19:06 +0200 Subject: NewtCanvasAWT: Cleanup up private method calls; Attach/Detach JAWTWindow's SurfaceUpdateListener to NEWT Window when it gets attached/detached. --- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index d22e50cb8..3d907a86f 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -421,15 +421,13 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto @Override public void paint(Graphics g) { - if( validateComponent(true, null) ) { + if( validateComponent(true) ) { newtChild.windowRepaint(0, 0, getWidth(), getHeight()); } } @Override public void update(Graphics g) { - if( validateComponent(true, null) ) { - newtChild.windowRepaint(0, 0, getWidth(), getHeight()); - } + paint(g); } @SuppressWarnings("deprecation") @@ -440,7 +438,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if(DEBUG) { System.err.println("NewtCanvasAWT.reshape: "+x+"/"+y+" "+width+"x"+height); } - if( validateComponent(true, null) ) { + if( validateComponent(true) ) { // newtChild.setSize(width, height); } } @@ -490,22 +488,19 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto return res; } - private final boolean validateComponent(boolean attachNewtChild, java.awt.Container cont) { + private final boolean validateComponent(boolean attachNewtChild) { if( Beans.isDesignTime() || !isDisplayable() ) { return false; } if ( null == newtChild || null == jawtWindow ) { return false; } - if( null == cont ) { - cont = AWTMisc.getContainer(this); - } if( 0 >= getWidth() || 0 >= getHeight() ) { return false; } if( attachNewtChild && !newtChildAttached && null != newtChild ) { - attachNewtChild(cont); + attachNewtChild(); } return true; @@ -559,7 +554,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } - private final void attachNewtChild(java.awt.Container cont) { + private final void attachNewtChild() { if( null == newtChild || null == jawtWindow || newtChildAttached ) { return; // nop } @@ -569,7 +564,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto System.err.println("NewtCanvasAWT.attachNewtChild.0: win "+newtWinHandleToHexString(newtChild)+ ", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+ ", comp "+this+", visible "+isVisible()+", showing "+isShowing()+", displayable "+isDisplayable()+ - ", cont "+cont); + ", cont "+AWTMisc.getContainer(this)); } newtChildAttached = true; @@ -582,6 +577,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto System.err.println("NewtCanvasAWT.attachNewtChild.2: size "+w+"x"+h); newtChild.setSize(w, h); newtChild.reparentWindow(jawtWindow); + newtChild.addSurfaceUpdatedListener(jawtWindow); newtChild.setVisible(true); configureNewtChild(true); newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener @@ -607,6 +603,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto ", cont "+cont); } + newtChild.removeSurfaceUpdatedListener(jawtWindow); newtChildAttached = false; newtChild.setFocusAction(null); // no AWT focus traversal .. configureNewtChild(false); -- cgit v1.2.3