JMenuItem
(and in fact all children of AbstractButton
) derive their display text from the Action.NAME
property.
Try something more like...
public class ActionExit extends AbstractAction
{
private Model model;
public ActionExit(Model model)
{
this.model = model;
putValue(NAME, "Exit");
}
@Override
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
}
Also, the Action
class also defines the mnemonic
and accelerator
values.
Take a look at How to use Actions and the Action API for more details