-
Bug
-
Resolution: Fixed
-
P4
-
1.4.1
-
tiger
-
x86
-
windows_2000
Name: jk109818 Date: 02/12/2003
FULL PRODUCT VERSION :
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
Upon calling show on the frame the label actually appears
on screen, but no ancestor listeners are called. Instead
they have been called already upon new(). Later invocations
of show() and hide() show the expected behavior. Just the
first show() after new() does not cause any event.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. put JLabel in JFrame
2. add ancestorListener to JLabel
3. create this JFrame and show it
EXPECTED VERSUS ACTUAL BEHAVIOR :
the ancestorListener's ancestorAdded method should be
called when the frame is shown, but it is called when the
frame is created
actual output from source code:
calling new Frame
ancestorAdded
calling show
calling hide
ancestorRemoved
calling show
ancestorAdded
end
expected results:
calling new Frame
calling show
ancestorAdded
calling hide
ancestorRemoved
calling show
ancestorAdded
end
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package showingnotification;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
public class Frame2 extends JFrame {
JLabel jLabel2 = new JLabel();
public Frame2() {
jLabel2.addAncestorListener(new javax.swing.event.AncestorListener() {
public void ancestorAdded(AncestorEvent e) {
System.err.println("ancestorAdded");
}
public void ancestorRemoved(AncestorEvent e) {
System.err.println("ancestorRemoved");
}
public void ancestorMoved(AncestorEvent e) {
}
});
jLabel2.setText("Homo Sapiens");
getContentPane().add(jLabel2);
pack();
}
public static void main(String[] args) {
System.err.println("calling new Frame");
Frame2 frame = new Frame2();
System.err.println("calling show");
frame.show();
System.err.println("calling hide");
frame.hide();
System.err.println("calling show");
frame.show();
System.err.println("end");
System.exit(0);
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
use HierarchyListeners instead
(Review ID: 180190)
======================================================================
- relates to
-
JDK-6255827 REGRESSION: getDefaultButton returns null
- Resolved