JDK-4714939 : method java.awt.Component.repaint() doesn't calls update() for some Component
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.5
  • CPU: sparc
  • Submitted: 2002-07-15
  • Updated: 2002-07-22
  • Resolved: 2002-07-22
Related Reports
Duplicate :  
Description
This problem has to do with the method java.awt.Component.repaint().

According to the spec:
"public void repaint()
      Repaints this component. 
      This method causes a call to this component's update method as soon as possible. 
"
But with the current implemention, the method repaint() doesn't call the update() method for some light weight component.

See the following code fragment:
=============================================================
 public Status Component2004() {
    
        Frame fr = new Frame();
        FakeComponent fc = new FakeComponent();
        try {
            fr.setSize(200, 200);     
            fr.add(fc);
            fr.setVisible(true);
            synchronized (fr) {
                while (!fr.isShowing()) {
                    try {
                        fr.wait(50);
                    } catch (InterruptedException ie) {
                    }
                }
            }
            Graphics g = fc.getGraphics();
            fc.repaint();
            synchronized (fr) {
                while (fc.updateCatch == false) {
                    try {
                        fr.wait(50);
                    } catch (InterruptedException ie) {
                    }
                }
            }
            if (fc.updateCatch == false) {
                return Status.failed("Failed:  method did not call the update() method");
            }
            return Status.passed("OKAY");
        } finally {
            fr.dispose();
        } 
    }


    class FakeComponent extends Component {
        public boolean paintCatch  = false;
        public boolean updateCatch = false;
        
        public void paint(Graphics g) {
            paintCatch = true;
            super.paint(g);
        }
        
        public void update(Graphics g) {
            updateCatch = true;
            super.update(g);
        } 
    }
  
===============================================================================

The result of running the above code is that it keeps waiting and stays in while loop.

But if I changed FakeCompoennt extends Canvas instead of Component, the abvoe code passed.







Comments
EVALUATION This sounds similar to the root cause of 4627627. ###@###.### 2002-07-16 Name: ssR10077 Date: 07/22/2002 duplicate of 4627627 ======================================================================
16-07-2002