-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
1.4.0
-
x86
-
linux
Name: jk109818 Date: 02/19/2002
FULL PRODUCT VERSION :
java version "1.3.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)
AND
java version "1.4.0"
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 :
glibc-2.2.2-10
Linux silicon.sjm 2.4.2-2 #1 Sun Apr 8 19:37:14 EDT 2001
i586 unknown
Red Hat Linux release 7.1 (Seawolf)
EXTRA RELEVANT SYSTEM CONFIGURATION :
Using XFree86-4.0.3-5 with Xfce as WindowManager
A DESCRIPTION OF THE PROBLEM :
When JPopupMenu.show(Component invoker, int x, int y) is
called the JPopupMenu instance is normally displayed at
position (x,y). However if the JPopupMenu is displayed and
then dismissed by calling JPopupMenu.setVisible(false) then
the next call to JPopupMenu.show() is ignored. If
JPopupMenu.show() is called again the menu is displayed as
normal.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Start attached java application (java PopupTest)
2. Left click near top left of window - JPopupMenu will be
displayed
3. Click on window, outside of JPopupMenu - JPopupMenu will
be dismissed
4. With keyboard focus on the window, press "g" on the
keyboard - JPopupMenu will be displayed near top left of window
5. With keyboard focus on the window, press "g" again on the
keyboard - JPopupMenu will be dismissed
6. Left click near top left of window - JPopupMenu will NOT
be displayed
7. Left click again near top left of window - JPopupMenu
will be displayed
8. Terminate java process
EXPECTED VERSUS ACTUAL BEHAVIOR :
In step 7, despite the JPopupMenu method being called, the
JPopupMenu component is not displayed. I would expect for it
to be displayed every time.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Mouse event java.awt.event.MouseEvent[MOUSE_PRESSED,(13,9),mods=16,clickCount=1]
on null.contentPanefalse
Showing popup (mouse)
Mouse event
java.awt.event.MouseEvent[MOUSE_PRESSED,(151,120),mods=16,clickCount=1] on
null.contentPanetrue
Keyboard event java.awt.event.KeyEvent[KEY_PRESSED,keyCode=71,keyChar='g'] on
frame0false
Showing popup (keyboard)
Keyboard event java.awt.event.KeyEvent[KEY_PRESSED,keyCode=71,keyChar='g'] on
frame0true
Hiding popup
Mouse event
java.awt.event.MouseEvent[MOUSE_PRESSED,(17,13),mods=16,clickCount=1] on
null.contentPanefalse
Showing popup (mouse)
Mouse event
java.awt.event.MouseEvent[MOUSE_PRESSED,(19,15),mods=16,clickCount=1] on
null.contentPanefalse
Showing popup (mouse)
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
class PopupTest extends JFrame {
JPopupMenu popup;
Container contentPane;
public PopupTest() {
setSize(200,200);
contentPane=getContentPane();
contentPane.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent me) {
System.out.println("Mouse event "+me+
popup.isVisible());
if (!popup.isVisible())
showPopup(me.getX(),me.getY());
}
}
);
addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent ke) {
System.out.println("Keyboard event "+ke+
popup.isVisible());
togglePopup();
}
}
);
popup=new JPopupMenu();
popup.add(new JMenuItem("Item 1"));
popup.add(new JMenuItem("Item 2"));
popup.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent ke) {
System.out.println("Keyboard event "+ke+
popup.isVisible());
togglePopup();
}
}
);
setVisible(true);
}
public void showPopup(int x, int y) {
System.out.println("Showing popup (mouse)");
popup.show(contentPane,x,y);
}
public void togglePopup() {
if (popup.isVisible()) {
System.out.println("Hiding popup");
popup.setVisible(false);
} else {
System.out.println("Showing popup (keyboard)");
popup.show(contentPane,10,10);
}
}
public static void main(String[] args) {
new PopupTest();
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
None known, any suggestions would be appreciated
(Review ID: 138504)
======================================================================