Name: gm110360 Date: 05/30/2002
FULL PRODUCT VERSION :
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OPERATING SYSTEM VERSION :
Windows NT 4.00.1381
ADDITIONAL OPERATING SYSTEMS :
Linux
A DESCRIPTION OF THE PROBLEM :
I have included a small piece of code below that I am using.
I basically want to add a small component of my own (represented by the closePopup button)
to a JPopupMenu. When I finish performing operations on my component I want to close the popup
menu, which I am doing using the setVisible(false) method to hide the popup menu
However in I get a problem, when I click on any other button
in the Frame the event is not actionPerformed event is not thrown
for that click. Only when it is clicked for the second time
is the event thrown
See Forum Thread 249053
REGRESSION. Last worked in version 1.3.1
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run the above code
2. Click on the "Show Popup" button
3. Click the "Close popup" button in the menu
4. Click the "Test" button (A message box should appear)
5. Click on the "Test" button again. Now the message box appears.
EXPECTED VERSUS ACTUAL BEHAVIOR :
The Message Dialog should appear on the first click of the "Test" button
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
/**
*
* @author grantl
*/
public class PopupTest extends JFrame implements ActionListener {
private JButton showPopup, closePopup, test;
private JPopupMenu popup;
/** Creates a new instance of PopupTest */
public PopupTest() {
super();
init();
setVisible(true);
}
public void init() {
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);
}
});
getContentPane().setLayout(new GridLayout(3,1));
getContentPane().add(new JLabel("Test Label"));
getContentPane().add(test = new JButton("Test"));
getContentPane().add(showPopup = new JButton("Show popup"));
closePopup = new JButton("Close popup");
test.addActionListener(this);
showPopup.addActionListener(this);
closePopup.addActionListener(this);
popup = new JPopupMenu();
popup.add(closePopup);
pack();
}
public void actionPerformed(ActionEvent ae) {
if (ae.getSource().equals(showPopup)) {
Dimension d = showPopup.getSize();
popup.show(showPopup, 0, d.height);
}
else if (ae.getSource().equals(closePopup)) {
popup.setVisible(false);
}
else {
JOptionPane.showMessageDialog(this, "Test");
}
}
public static void main(String args[]) {
new PopupTest();
}
}
---------- END SOURCE ----------
Release Regression From : 1.3.1_03
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
(Review ID: 146023)
======================================================================