Below is my mouse event code for the clicking action. However this action doesnt work for me. How should i change this to work?
private void menuSelectallMouseClicked(java.awt.event.MouseEvent evt) {
menuSelectall.getActionMap().get(DefaultEditorKit.selectAllAction)
menuSelectall.setText("Select All");
}
You don't use a MouseListener to handle events on a popup menu, the menu item should already be created with the specific Action.
You just create a JMenuItem using the Action from the EditorKit and then you add the menu item to your JPopupMenu. The code should be something like:
The menu item will than handle the mouse event and invoke the Action.