Page 415 - CITS - Computer Software Application -TT
P. 415

COMPUTER SOFTWARE APPLICATION - CITS




                   public void actionPerformed(ActionEvent e) {
                     String command = e.getActionCommand();

                     if( command.equals( “OK” ))  {
                         statusLabel.setText(“Ok Button clicked.”);
                     }
                     else if( command.equals( “Submit” ) )  {

                         statusLabel.setText(“Submit Button clicked.”);
                     }
                     else  {
                          statusLabel.setText(“Cancel Button clicked.”);
                     }
                   }

                 }
              }

           Introduction to Event Handling Classes


           EventObject class:-
           It is the root class from which all event state objects shall be derived. All Events are constructed with a reference
           to the object, the source, that is logically deemed to be the object upon which the Event in question initially
           occurred upon. This class is defined in java.util package.
           Class declaration
           Following is the declaration for java.util.EventObject class:
           public  class  EventObject  extends  Object  implements  Serializable  Field  Following  are  the  fields  for  java.util.
           EventObject class:
           protected Object source -- The object on which the Event initially occurred.
           Class constructors

           Constructor & Description
           EventObject(Object source)
           Constructs a prototypical Event.
           Class methods
           Method & Description
           Object getSource()

           The object on which the Event initially occurred.
           String toString()
           Returns a String representation of this EventObject.
           Methods inherited

           This class inherits methods from the following classes:
           java.lang.Object
           AWT Event Classes:
           Following is the list of commonly used event classes.



                                                           402

                             CITS : IT&ITES - Computer Software Application - Lesson 116 - 119
   410   411   412   413   414   415   416   417   418   419   420