From 2714f044cd64087dc4d1a7ad4ec652e2e8e157ed Mon Sep 17 00:00:00 2001
From: Kenneth Russel
@@ -248,6 +250,94 @@ class MyListener implements GLEventListener {
++ +As mentioned above, JOGL supplies both a heavyweight (GLCanvas) and a +lightweight (GLJPanel) widget to be able to provide the fastest +possible performance for applications which need it as well as 100% +correct Swing integration, again for applications which need it. The +GLCanvas provides much higher performance than the GLJPanel in nearly +all situations and can be used in almost every kind of application +except those using JInternalFrames. Please see the Swing Connection +article mentioned above for details on mixing heavyweight and +lightweight widgets. A couple of common pitfalls are described here. + +
+
+
+When using JPopupMenus or Swing tool tips in conjunction with the
+GLCanvas, it is necessary to disable the use of lightweight widgets
+for the popups. See the methods
+ToolTipManager.setLightWeightPopupEnabled
,
+JPopupMenu.setLightWeightPopupEnabled
, and
+JPopupMenu.setDefaultLightWeightPopupEnabled
.
+
+
+ +There are occasionally problems with certain LayoutManagers and +component configurations where if a GLCanvas is placed in the middle +of a set of lightweight widgets then it may only grow and never +shrink. These issues are documented somewhat in JOGL Issue +135 and most recently in the thread "Resize +behaviour" in the JOGL forum. The root cause is behavior of the +Canvas, and in particular its ComponentPeer. The implementation of +getPreferredSize() calls getMinimumSize() and getMinimumSize() turns +around and calls Component.getSize(). This effectively means that the +Canvas will report its preferred size as being as large as the +component has ever been. For some layout managers this doesn't seem to +matter, but for others like the BoxLayout it does. See the test case +attached to Issue 135 for an example. Replacing the GLCanvas with an +ordinary Canvas yields the same behavior. + +
++ +One suggestion was to override getPreferredSize() so that if a +preferred size has not been set by the user, to default to (0, +0). This works fine for some test cases but breaks all of the other +JOGL demos because they use a different LayoutManager. There appear to +be a lot of interactions between heavyweight vs. lightweight widgets +and layout managers. One experiment which was done was to override +setSize() in GLCanvas to update the preferred size. This works down +to the size specified by the user; if the window is resized any +smeller the same problem appears. If reshape() (the base routine of +setSize(), setBounds(), etc.) is changed to do the same thing, the +demo breaks in the same way it originally did. Therefore this solution +is fragile because it isn't clear which of these methods are used +internally by the AWT and for what purposes. + +
+
+
+There are two possible solutions, both application-specific. The best
+and most portable appears to be to put the GLCanvas into a JPanel and
+set the JPanel's preferred size to (0, 0). The JPanel will cause this
+constraint to be enforced on its contained GLCanvas. The other
+workaround is to call setPreferredSize(new Dimension(0,
+0))
on a newly-created GLCanvas; this method is new in 1.5.
+
+
+
+Another issue that occasionally arises on Windows is flickering during
+live resizing of a GLCanvas. This is caused by the AWT's repainting
+the background of the Canvas and can not be overridden on a per-Canvas
+basis, for example when subclassing Canvas into GLCanvas. The
+repainting of the background of Canvases on Windows can be disabled by
+specifying the system property
+-Dsun.awt.noerasebackground=true
. Whether to specify this
+flag depends on the application and should not be done universally,
+but instead on a case-by-case basis. Some more detail is in the thread
+"TIP: JOGL
++ Swing flicker" in the JOGL forum.
+
+
-- cgit v1.2.3