JPopupMenu and Jmenu problem
I have a JPopupMenu
lets call it (aaa) inside it i have Jmenu(mmm)
,contain some JmenuItems(like b,c,d,k)
.
this popup menu shows at right click on the panel ,and on mouse over mmm menu the sub menu (b,c,d,k)
appear ,but if i goes down a little bit under the mmm menu ,the sub menu (b,c,d,k)
disappear ,how i can solve this to be more friendly ?can i make the sub menu (b,c,d,k)
appear with left mouse click over the mmm menu?
JPopupMenu aaa = new JPopupMenu();
JMenu mmm = new J开发者_开发知识库Menu("mmm");
JMenuItem b = new JMenuItem("b");
JMenuItem c = new JMenuItem("c");
JMenuItem d = new JMenuItem("d");
JMenuItem k = new JMenuItem("k");
mmm.add(b);
mmm.add(c);
mmm.add(d);
mmm.add(k);
aaa.add(mmm);
Not able to reproduce your problem. This is what I have tried:
JFrame frame = new JFrame();
frame.setSize(300,300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
JPopupMenu aaa = new JPopupMenu();
JMenu mmm = new JMenu("mmm");
JMenuItem b = new JMenuItem("b");
JMenuItem c = new JMenuItem("c");
JMenuItem d = new JMenuItem("d");
JMenuItem k = new JMenuItem("k");
mmm.add(b);
mmm.add(c);
mmm.add(d);
mmm.add(k);
aaa.add(mmm);
panel.setComponentPopupMenu(aaa);
frame.add(panel);
frame.setVisible(true);
Nothing gets disappears. Is this the same you are doing?
精彩评论