Re: Difference between itemStateChanged and stateChanged for a JCheckBoxMenuItem
- From: Nomak <none@xxxxxxxxxxxxxxxxx>
- Date: Fri, 29 Apr 2005 09:56:43 +0200
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
.
- References:
- Prev by Date: Re: JMenu holding JButton instances - bug with 5.0?
- Next by Date: Re: BoxLayout making component too big
- Previous by thread: Re: Difference between itemStateChanged and stateChanged for a JCheckBoxMenuItem
- Next by thread: Replace row in JTable
- Index(es):