Sometimes in java, while we do GUI programming to prepare software we add menu bar(For example javax.swing.JMenuItem jMenuItem).In the menu bar we add various menu items according to our necessity.
While adding menu item, we have to indicate which menu item is clicked and which action need to be performed on that click.
Here I have given a code snippet to identify which menu item is clicked.
private javax.swing.JMenuItem jMenuItem = null;
private javax.swing.JMenuItem jMenuItem1 = null;
jMenuItem.setText(“Approve” );
jMenuItem1.setText(“Reject” );
if(jMenuItem.getText().trim().equalsIgnoreCase(“Approve” ) )
{
Do the following action
——-
—-
}