Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6726866

Repainting artifacts when resizing or dragging JInternalFrames in non-opaque toplevel

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 6u10
    • Fix Version/s: 6u12
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b02
    • CPU:
      x86
    • OS:
      windows_xp

      Backports

        Description

        As discussed in this thread:
          http://forums.java.net/jive/thread.jspa?threadID=43881&tstart=0

        The following test case shows rendering artifacts in non-opaque toplevels
        when JInternalFrames are used:
        public class NonOpaqueWindowTest2 extends JFrame
        {
          public NonOpaqueWindowTest2()
          {
            super();
            setWindowNonOpaque(this);
            
            JDesktopPane desktop = new JDesktopPane();
            JInternalFrame iFrame = new JInternalFrame("Test", true, true, true, true);
            iFrame.add(new JLabel("internal Frame"));
            iFrame.setBounds(10, 10, 300, 200);
            iFrame.setVisible(true);
            desktop.add(iFrame);
            getContentPane().add(desktop);
            
            setTitle(getClass().getSimpleName());
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setSize(400, 400);
            setLocationRelativeTo(null);
            setVisible(true);
          }
          
          private void setWindowNonOpaque(Window w)
          {
            try
            {
              Class<?> c = Class.forName("com.sun.awt.AWTUtilities");
              Method m = c.getMethod("setWindowOpaque", Window.class, boolean.class);
              m.invoke(null, w, false);
            }
            catch (Exception e)
            {
              e.printStackTrace();
            }
          }
         
          public static void main(String[] args) throws Exception
          {
            EventQueue.invokeLater(new Runnable(){
              public void run()
              {
                JFrame.setDefaultLookAndFeelDecorated(true);
                new NonOpaqueWindowTest2();
              }
            });
          }
        }

          Issue Links

            Activity

            Hide
            tdv Dmitri Trembovetski (Inactive) added a comment -
            BT2:EVALUATION

            This is reproducible with and w/o the d3d pipeline enabled it it is likely related
            to the way repainting of non-opaque swing toplevels is handled.
            Show
            tdv Dmitri Trembovetski (Inactive) added a comment - BT2:EVALUATION This is reproducible with and w/o the d3d pipeline enabled it it is likely related to the way repainting of non-opaque swing toplevels is handled.
            Hide
            alexp Alexander Potochkin (Inactive) added a comment -
            BT2:EVALUATION

            We use painting optimization when internalFrame is being dragged,
            in this case we use currentManager.copyArea() method
            which doesn't work for the non-opaque topLevels

            Note that problems with resizing of internal frames
            are covered by another CR #6738762
            Show
            alexp Alexander Potochkin (Inactive) added a comment - BT2:EVALUATION We use painting optimization when internalFrame is being dragged, in this case we use currentManager.copyArea() method which doesn't work for the non-opaque topLevels Note that problems with resizing of internal frames are covered by another CR #6738762
            Hide
            alexp Alexander Potochkin (Inactive) added a comment -
            BT2:EVALUATION

            When FASTER_DRAG_MODE is on, DefaultDesktopManager.dragFrameFaster() is responsible for painting dragged internal frame. However it fails to paint when the top level frame is non-opaque (the new 6u10 feature, see com.sun.awt.AWTUtilities) because AWT invokes frame.paint() to repaint its content and all kind of painting optimizations that are not reflected in paint() method, skipped by AWT.

            dragFrameFaster() uses RepaintManager.copyArea() to speed the painting up,
            it is certainly bypasses by usual paint() routine, so this optimizations is to be switched off for non-opaque windows.

            Another point is OUTLINE_DRAG_MODE, for this property DefaultDesktopManager.dragFrame()
            paints decorations on the JComponent.safelyGetGraphics(desktopPane);
            this is also can't be caught by AWT. Supporting this mode for non-opaque window
            requires non trivial refactoring, because the whole DefaultDesktopManager painting is to be affected. This is too risky for update release.

            I decided to always use DEFAULT_DRAG_MODE for non-opaque windows,
            because it seems to be only reliable solution in this situation
            Show
            alexp Alexander Potochkin (Inactive) added a comment - BT2:EVALUATION When FASTER_DRAG_MODE is on, DefaultDesktopManager.dragFrameFaster() is responsible for painting dragged internal frame. However it fails to paint when the top level frame is non-opaque (the new 6u10 feature, see com.sun.awt.AWTUtilities) because AWT invokes frame.paint() to repaint its content and all kind of painting optimizations that are not reflected in paint() method, skipped by AWT. dragFrameFaster() uses RepaintManager.copyArea() to speed the painting up, it is certainly bypasses by usual paint() routine, so this optimizations is to be switched off for non-opaque windows. Another point is OUTLINE_DRAG_MODE, for this property DefaultDesktopManager.dragFrame() paints decorations on the JComponent.safelyGetGraphics(desktopPane); this is also can't be caught by AWT. Supporting this mode for non-opaque window requires non trivial refactoring, because the whole DefaultDesktopManager painting is to be affected. This is too risky for update release. I decided to always use DEFAULT_DRAG_MODE for non-opaque windows, because it seems to be only reliable solution in this situation

              People

              • Assignee:
                alexp Alexander Potochkin (Inactive)
                Reporter:
                tdv Dmitri Trembovetski (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: