Details
-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
6
-
generic
-
generic
Description
J2SE Version (please include all output from java -version flag):
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b75)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b75, mixed mode, sharing)
Does this problem occur on J2SE 1.4.x or 5.0.x ? Yes / No (pick one)
Yes
Operating System Configuration Information (be specific):
Microsoft Windows 2000 [Version 5.00.2195]
problem with ComponentListener documentation
The ComponentListener.componentHidden(ComponentEvent e) documentation
says 'Invoked when the component has been made invisible.'
As can be seen from the following code when
componentHidden(ComponentEvent e) is invoked the component is Visible.
If this is the expected behaviour then I would expect the documentation
to say something like 'Invoked sometime after the component was made
invisible'
(likewise for the other methods in ComponentListener)
import java.awt.event.*;
import javax.swing.*;
import static javax.swing.JFrame.*;
import static java.lang.System.*;
public class Test {
public static void main(String[] args) {
JFrame frame = new JFrame();
JButton button = new JButton("Press Me");
button.addComponentListener(new ComponentAdapter() {
public void componentShown(ComponentEvent e) {
out.println("componentShown - visible: " +
e.getComponent().isVisible());
}
public void componentHidden(ComponentEvent e) {
out.println("componentHidden - visible: " +
e.getComponent().isVisible());
}
});
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent anEvent) {
JButton button = (JButton)anEvent.getSource();
button.setVisible(false);
button.setVisible(true);
}
});
frame.add(button);
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.setSize(500, 500);
frame.setVisible(true);
}
}
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b75)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b75, mixed mode, sharing)
Does this problem occur on J2SE 1.4.x or 5.0.x ? Yes / No (pick one)
Yes
Operating System Configuration Information (be specific):
Microsoft Windows 2000 [Version 5.00.2195]
problem with ComponentListener documentation
The ComponentListener.componentHidden(ComponentEvent e) documentation
says 'Invoked when the component has been made invisible.'
As can be seen from the following code when
componentHidden(ComponentEvent e) is invoked the component is Visible.
If this is the expected behaviour then I would expect the documentation
to say something like 'Invoked sometime after the component was made
invisible'
(likewise for the other methods in ComponentListener)
import java.awt.event.*;
import javax.swing.*;
import static javax.swing.JFrame.*;
import static java.lang.System.*;
public class Test {
public static void main(String[] args) {
JFrame frame = new JFrame();
JButton button = new JButton("Press Me");
button.addComponentListener(new ComponentAdapter() {
public void componentShown(ComponentEvent e) {
out.println("componentShown - visible: " +
e.getComponent().isVisible());
}
public void componentHidden(ComponentEvent e) {
out.println("componentHidden - visible: " +
e.getComponent().isVisible());
}
});
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent anEvent) {
JButton button = (JButton)anEvent.getSource();
button.setVisible(false);
button.setVisible(true);
}
});
frame.add(button);
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.setSize(500, 500);
frame.setVisible(true);
}
}
Attachments
Issue Links
- duplicates
-
JDK-4982900 Should document asynchronicity of event processing in AWT package docs
- Closed