Reputation: 483
I would insert from right menu the option to select all the nodes of a tree. This functionality is implemented in standard pressing ctrl-a. How do I similura that functionality?
JTree tree = new JTree();
JPopupMenu popMenuTree = new JPopupMenu();
JMenuItem selectAll = new JMenuItem();selectAll.setText("SelectAll");
selectAll.setActionCommand("selectAll");
KeyStroke ctrlXKeyStroke = KeyStroke.getKeyStroke("control A");
selectAll.setAccelerator(ctrlXKeyStroke);
popMenuTree.add(selectAll);
thank you so much
Upvotes: 0
Views: 184
Reputation: 15113
Because popup menus, unlike regular menus, aren't always contained by a component, accelerators in popup menu items don't work unless the popup menu is visible.
Upvotes: 1