Delegation of event modelling in java

Unknown | 02:21 | 0 comments

event modelling in java


Delegation of Event Modelling
  • Hi Students I am going to write Article on Delegation of Event Modelling in simplified Manner.
  • When an event occurs we programmers has 3 options for handling events  
                             1. Let it happen what ever happen(ignore event).
                             2. Let any other component manage the event.
                            *3. Let Delegate its handling to some other object called Listener.


   According to delegation of event modeling,For example when a button click or option
  Selected by user, Then Listener if we connected listen to the event, and then it invokes
  A method called action performed.

                                                   

Detailed Table for Event Modelling 

CONTROL                            LISTENER                          METHODS AND EVENTS

Button                                 Action Listener                  actionPerformed(ActionEvent e) 
List                                     Action Listener                  actionPerformed(ActionEvent e)     
MenuItem                            Action Listener                  actionPerformed(ActionEvent e)
TextField                                      Action Listener                  actionPerformed(ActionEvent e)

Checkbox                            ItemListener                     itemStateChanged(ItemEvent e)
Choice                                ItemListener                     itemStateChanged(ItemEvent e)
List                                     ItemListener                     itemStateChanged(ItemEvent e)
Checkbox MenuItem             ItemListener                     itemStateChanged(ItemEvent e)

DialogFrame                        WindowListener                windowOpened(WindowEvent e)
DialogFrame                        WindowListener                windowClosing(WindowEvent e)
DialogFrame                        WindowListener              windowMinimized(WindowEvent e)

Scrollbar                             AdjustmentListener            adjustmentValueChanged
                                                                                      (AdjustmentEvent e)

Canvas                                MouseListener                   mousePressed(MouseEvent e)
Dialog                                 MouseListener                   mouseReleased(MouseEvent e)
frame                                 MouseListener                   mouseEntered(MouseEvent e)
Panel                                  MouseListener                   mouseExisted(MouseEvent e)
Window                              MouseListener                   mouseClicked(MouseEvent e)

Component                         KeyListener                       keyTyped(KeyEvent e)
Component                         KeyListener                       keyPressed(KeyEvent e)
Component                         KeyListener                       keyReleased(KeyEvent e)

Component                         FocusListener                     focusGained(FocusEvent e)
Component                         FocusListener                     focusLost(FocusEvent e)t

TextComponent                  TextListener                        textValueChanged(TextEvet e)

  Events and Methods

ActionEvent:
                   
1.When button is get clicked
2.When menu item is selected
3.When list item is double clicked
4.When enter key pressed in text field

Method: 

-------------->getSource() gives the source that made this event

ItemEvent:

1.When a check box is selected/deselected 
2.When choice item is selected/deselected 
3.When list item is selected/deselected
4.When check box menu item is selected/deselected 

Method: 

-------------->getItemSelectable() gives reference to the item selected component
                   getItem() gives reference to the item that caused the event


AdjustmentEvent:

1.When a scroll bar thumb is moved

 Method: 

-------------->getAdjustable() gives the object that caused the event
                   getValue()        gives the new value 

TextEvent:

1.When content of text is changed in TextField,TextArea

MouseEvent:

1.When user clicks or moves the mouse pointer 

Method: 

------------->getX(),getY()       gives x,y screen coordinates of mouse position
                   getClickCount()  gives click count for an event

WindowEvent:

1.When a window minimized ,opened ,activated etc.

FocusEvent:

1.When a component gains or loses focus

KeyEvent:

1.Its is generated by the user during interaction from keyboard

Method: 

 1.getKeyCode() gives the key code for a given char
 2.getkeyChar()  gives char defined by a key code.






         


Category: ,

handsonbook.blogspot.com

0 comments