wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes ActionEvent or Itemevent? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ActionEvent or Itemevent?" Watch "ActionEvent or Itemevent?" New topic
Author

ActionEvent or Itemevent?

Lalit Sha
Greenhorn

Joined: Jan 11, 2001
Posts: 28
You have a user interface that shows a java.awt.List of named colors from which the user can select to set the background of an application. Which event is generated when one of the names is selected? The answer says Itemevent. Could anybody tell me why ItemEvent and not ActionEvent?
Thankx,
Lalit.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Because a List is more complicated than a Button or some other component. When you press a Button, an event is fired and that's all that you need to know.
When you select an item from a list you need to know MORE that just that "something" happened. You need to know WHAT was selected.
List implements the ItemSelectable interface to provide this more sophisticated functionality.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Just thought I'd add that double-clicking a list item does generate an action event.

Bosun


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
 
GeeCON Prague 2014
 
subject: ActionEvent or Itemevent?