How to code which CheckBoxMenuItem is selected in Java?
<p>I am trying to add a method which takes the menu selection and passes it to a variable.
In this case I would like to take "7" and insert that into the year variable if
that is what is selected from teh checkboxmenu.  So far have search the internet
and sun site with no clear example on how to differentiate the menu items.  Any
suggestions would be appreciated thanks.</p>

<pre><code>cbMenuItem = new JCheckBoxMenuItem("7 year");
cbMenuItem.setMnemonic(KeyEvent.VK_H);
cbMenuItem.addItemListener(this);
menu.add(cbMenuItem);

cbMenuItem = new JCheckBoxMenuItem("15 year");
cbMenuItem.setMnemonic(KeyEvent.VK_S);
cbMenuItem.addItemListener(this);
menu.add(cbMenuItem);
</code></pre>
