This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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
 
Consider Paul's rocket mass heater.
 
subject: ActionEvent or Itemevent?