Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ActionEvent or Itemevent?

 
Lalit Sha
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bosun Bello
Ranch Hand
Posts: 1510
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just thought I'd add that double-clicking a list item does generate an action event.

Bosun
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic