JDK-4827244 : adding component takes too long (5seconds on 1.4 against 10ms on 1.3)
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2003-03-04
  • Updated: 2013-11-01
  • Resolved: 2003-09-03
Related Reports
Duplicate :  
Description

Name: gm110360			Date: 03/04/2003


FULL PRODUCT VERSION :
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

FULL OPERATING SYSTEM VERSION :Microsoft Windows 2000
[Version 5.00.2195]


ADDITIONAL OPERATING SYSTEMS :XP



A DESCRIPTION OF THE PROBLEM :
If I add a Panel to the "center" of another Panel that has
a BorderLayout, it works fine.  If I remove the Panel, and
add another one, it works fine.  If i remove this other one
and add the first one again, it takes up 5 seconds to do
tha add call.  I tried it out in JRE1.3 and it works fine
always.  Only JRE1.4 has the problem, both in appletviewer
and the plugin.  My parent Panel has a BorderLayout with a
series of buttons at NOrth position.  Pressing one of these
buttons changes the center Panel.  The first time the
center panel is added (and built and addNotify is called)
it is fast (10ms).  I click another button (at north) so
the center panel is removed and replaced by another panel,
and click back the previous button (to put back the fst
center panel), and the cpu runs at 100% for 5 seconds.
Again, Previous JRE don't do that, and M$ VM neither, so I
think it is a bug of JRE1.4.1.

REGRESSION.  Last worked in version 1.3

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.create an applet, add a panel to east borderlayout
2.the added panel (A) has a north panel and center panel
3.successively add and remove the same 2 panels to the
center position of (A).  Second time they are added, it
takes up 5 seconds as opposed to 10ms fst time.  (these
panels have flowlayout of panels).

EXPECTED VERSUS ACTUAL BEHAVIOR :
Consistent time to add and remove the same panels that are
previously built.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
no error, but machine appear as hung for 5 seconds...

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class Bug extends Applet implements ActionListener
{
    Button b1, b2;
    Panel current;
    Panel subCenter1, subCenter2;
    Panel mainEast;
    public void init() {
        setSize(600, 600);
        setLayout(new BorderLayout(5,5));
        Panel mainCenter = new Panel();
        mainCenter.setBackground(Color.red);
        mainCenter.setSize(200, 200);
        add(mainCenter, BorderLayout.CENTER);
        mainEast = new Panel(new BorderLayout(5, 5));
        add(mainEast, BorderLayout.EAST);
        Panel subNorth = new Panel(new FlowLayout());
        subCenter1 = new Panel();
        subCenter1.setBackground(Color.green);
        subCenter2 = new Panel();
        subCenter2.setBackground(Color.yellow);
        mainEast.add(subNorth, BorderLayout.NORTH);
        mainEast.add(subCenter1, BorderLayout.CENTER);
        b1 = new Button("bt1");
        b2 = new Button("btn2");
        b1.addActionListener(this);
        b2.addActionListener(this);
        subNorth.add(b1);
        subNorth.add(b2);
        validate();
        subCenter1.setSize(subCenter1.getSize());
        subCenter2.setSize(subCenter1.getSize());
        current = subCenter1;
    }
    
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == b1 && current != subCenter1) {
            mainEast.remove(current);
            current = subCenter1;
            mainEast.add(current);
            mainEast.validate();
            repaint();
        } else if (e.getSource() == b2 && current != subCenter2) {
            mainEast.remove(current);
            current = subCenter2;
            mainEast.add(current);
            mainEast.validate();
            repaint();
        }
    }
}


<html>
<body>
<center>

<APPLET CODE="Bug"
         codebase="."
         WIDTH="600"
	HEIGHT="600"
        >

</APPLET>

</center>
</body>
</html>

---------- END SOURCE ----------

CUSTOMER WORKAROUND :
no workaround
(Review ID: 181864) 
======================================================================

Comments
EVALUATION Sounds like 4745222. I'm not sure if 4675054 is also related. ###@###.### 2003-03-06 I verified that this is the same problem as 4745222. ###@###.### 2003-09-03
06-03-2003