Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4223341

Problem with PopupMenu in Windows

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 1.2.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_nt

      Description



      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)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mmartaksunw Michael Martak (Inactive)
              Reporter:
              vasya Vassili Igouchkine (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: