-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
1.4.0
-
x86
-
generic
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();
}
}
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();
}
}
- duplicates
-
JDK-4407702 Heavyweight Popup in the Combo box should not get focus for keyboard navigation
- Closed