Java Event Handling
Java Event Handling
Java Event
Event Handling
Handling
--
Component
EventListener ScrollBar
interface *
AdjustmentListener adjustmentListeners
+addAdjustmentListener:
InputScrollbarAdapter
+adjustmentValueChanged:
Mari Göransson - KaU - Datavete 3
nskap - DAVD11
Event Representation
• Each event is represented by an
object that gives information
about the event and identifies the
event source.
• In Java, every event is a subclass
of EventObject.
Component
AWTEvent
By the classes
TextComponent
implementing <<use>> ActionEvent <<create>>
the interface
EventListener
interface * TextField
ActionListener
+addActionListener:
ItemListener InputTextAdapter
AdjustmentListener
ConverterModel
+actionPerformed:
+itemStateChanged:
+actionPerformed:
+addTreatmentListener:
ManickAdapter
+treatment1Occured: MySimpleListener
+treatment2Occured:
+treatmentnOccured:
+treatmentxOccured:
<<use>> <<create>>
EventListener
interface * Component
ItemListener Choice
+addItermListener:
ActionListener
AdjustmentListener
ConverterModel
+itemStateChanged:
+actionPerformed:
Mari Göransson - KaU - Datavete 27
nskap - DAVD11
ItemEvent
• The event is passed to every
ItemListener object which registered to
receive such events using the
component's addItemListener()
method.
• When an item-selection event occurs,
the listener object's
itemStateChanged() method is invoked.