setVisible doesn't work in Java 1.7 build 25

Sun bug # 6722346

 

The method setVisible should show a component that has been added but set so it is not visible.

Steps to reproduce the problem:

Click the button "Click to make a hidden button appear"

Expected result:

A button "This button was hidden" should appear

Observed result:

Using Java 1.7 build 25 the button does not appear.

Other environments tested:

This works as expected in Java 1.6.0_05 and Java 1.7 build 23.

This bug was fixed in Java 1.7 build 36.


If you have any insights, workarounds or comments about this test page please contact Mickey Segal.  A listing of many Java resources is at this link.

Source code:

import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class ShowComponent extends Applet implements ActionListener {

Button button1, button2;

public void init()
{
    button1 = new Button("Click to make a hidden button appear");
    add(button1);
    button1.addActionListener(this);
    button2 = new Button("This button was hidden");
    add(button2);
    button2.setVisible(false);
}

public void actionPerformed(ActionEvent ae)
{
    if (ae.getSource() == button1)
    {
    button2.setVisible(true);
    invalidate();
    validate();
    }
}
} // END OF Class ShowComponent