-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.2.0
-
x86
-
windows_nt
Name: vi73552 Date: 03/23/99
//Consider the following code :
import java.awt.* ;
import java.awt.event.* ;
public class Bug extends Frame implements ActionListener
{
private PopupMenu mnuPop ;
private Button btn ;
public Bug ()
{
super ("PopupMenu bug") ;
Menu mnu ;
mnuPop = new PopupMenu () ;
mnu = new Menu ("1st SubMenu") ;
mnu.add (new MenuItem ("1st MenuItem")) ;
mnu.add (new MenuItem ("2nd MenuItem")) ;
mnu.add (new MenuItem ("3rd MenuItem")) ;
mnuPop.add (mnu) ;
add (btn = new Button("Nix"),BorderLayout.CENTER) ;
btn.addActionListener (this) ;
btn.add (mnuPop) ;
setSize (100, 100) ;
show () ;
}
public void actionPerformed (ActionEvent ae)
{
mnuPop.show (btn, 0, 0) ;
/* this should display a menu with the proper text in all menus and menuitems. Instead, I get a menu made of buttons, and all buttons have the same caption, i.e "Nix". I'm getting
+--------+--------+ +---------------+--------------+
| Nix >| Nix | | 1st SubMenu >| 1st MenuItem |
+--------+--------+ +---------------+--------------+
| Nix | instead of | 2nd MenuItem |
+--------+ +--------------+
| Nix | | 3rd MenuItem |
+--------+ +--------------+
.
If, on the other hand, I add the menu to the frame itself, without creating the button and adding a MouseListener which will show the menu on mousePressed, it works fine.
*/
}
public static void main (String args[])
{
new Bug () ;
}
}
/* Conclusion : I guess 'PopupMenu'-s weren't meant to be added to buttons ... */
(Review ID: 55532)
======================================================================
- duplicates
-
JDK-4181790 Popup menu displayed incorrect entries on Win32 on 1.1.6, 1.2
-
- Closed
-