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

JPopupMenu:Keyboard navigation not working if the popup is at the boundaries.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 1.4.0
    • client-libs

      Found keyboard navigation not working in Solaris as well as Windows platforms if the popup menu boundaries exceed the boundaries of its caller. As a result, could not use mnemonics and also could not cancel an opened (using mouse) popup menu using 'Esc' key.

      Code used:
      ---------
      import java.awt.*;
      import java.util.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class PopupMenuTest extends JFrame {
        private Label label = new Label("Click here for popup");
        private JPopupMenu pMenu;
        private JMenuItem mItem;
        
        public PopupMenuTest() {
          //label.setPreferredSize(new Dimension(250, 250));
          
          pMenu = new JPopupMenu();
          
          mItem = new JMenuItem("One");
          mItem.setMnemonic(KeyEvent.VK_O);
          pMenu.add(mItem);
          
          mItem = new JMenuItem("Two");
          mItem.setMnemonic(KeyEvent.VK_T);
          pMenu.add(mItem);
          
          mItem = new JMenuItem("Three");
          mItem.setMnemonic(KeyEvent.VK_H);
          pMenu.add(mItem);
              
          label.addMouseListener(new MouseAdapter(){
            public void mousePressed(MouseEvent e) {
              pMenu.show(label, e.getX(), e.getY());
            }
          });
              
          getContentPane().add(label, BorderLayout.CENTER);
        }
        
        public static void main(String s[]) {
          PopupMenuTest p = new PopupMenuTest();
          p.setVisible(true);
          p.pack();
        }
      }

            mdavidsosunw Mark Davidson (Inactive)
            sramansunw Sridhar Raman (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: