Re: Difference between itemStateChanged and stateChanged for a JCheckBoxMenuItem



On Thu, 28 Apr 2005 21:56:25 GMT
"John McGrath" <ng@xxxxxxxxxxxxx> wrote:

> On 4/28/2005 at 12:18:13 PM, Nomak wrote:
>
> > which one is better to use for a JCheckBoxMenuItem:
> > - itemStateChanged
> > or
> > - stateChanged
>
> That depends on what you want to do with it.
>
> ChangeListener (stateChanged) is a very general interface which is use by
> many different components. ChangeEvents are usually fired when *any*
> state changes. A JCheckBoxMenuItem will fire a change event when the menu
> item is armed, highlighted, selected, etc, and you will normally receive
> many ChangeEvents as the user interacts with the JCheckBoxMenuItem. The
> event will not tell you anything about what changed - you will need to
> look at the event source and figure that out yourself.
>
> ItemListener (itemStateChanged) is used for components that can be
> selected or deselected, such as toggle buttons, checkboxes and radio
> buttons. You will receive a single ItemEvent each time the selection
> changes and the event has a getStateChange() method that will tell you
> whether it was a selection or deselection.

thx a lot
.