I got one JMenuItem with start code. How can I get when I click one icon that the code will start?
private void jMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
String color="blue";
}
private void IconActionPerformed(java.awt.event.ActionEvent evt) {
// here i dont know how start JmenuItem when i click on it
get.jMenuItemActionPerformed;
}
Looks like you haven’t added an
ActionListenerto yourJMenuItem. AnActionListenerwaits until some action is performed (e.g. clicking) on a GUI component, then calls some code. For example: