eXtropia: the open web technology company
Technology | Support | Tutorials | Development | About Us | Users | Contact Us
 ::   Tutorials
 ::   Presentations
Perl & CGI tutorials
 ::   Intro to Perl/CGI and HTML Forms
 ::   Intro to Windows Perl
 ::   Intro to Perl 5
 ::   Intro to Perl
 ::   Intro to Perl Taint mode
 ::   Sherlock Holmes and the Case of the Broken CGI Script
 ::   Writing COM Components in Perl

Java tutorials
 ::   Intro to Java
 ::   Cross Browser Java

Misc technical tutorials
 ::   Intro to The Web Application Development Environment
 ::   Introduction to XML
 ::   Intro to Web Design
 ::   Intro to Web Security
 ::   Databases for Web Developers
 ::   UNIX for Web Developers
 ::   Intro to Adobe Photoshop
 ::   Web Programming 101
 ::   Introduction to Microsoft DNA

Misc non-technical tutorials
 ::   Misc Technopreneurship Docs
 ::   What is a Webmaster?
 ::   What is the open source business model?
 ::   Technical writing
 ::   Small and mid-sized businesses on the Web

Offsite tutorials
 ::   ISAPI Perl Primer
 ::   Serving up web server basics
 ::   Introduction to Java (Parts 1 and 2) in Slovak


Introduction to Web Programming
Event Propagation  
  • In our button example, we subclassed a button in order to handle its events. However, if this were the only way you could handle events, things would get cumbersome fairly quickly. If we needed to subclass each control that we wanted to handle events for, the number of classes in our code would get large and unwieldy quickly. Happily, this isn't the case. Events aren't just passed to the superclasses of the components where the events occur; they are also passed to the parents of those components.

  • For example, if our button was placed in a dialog, we could also handle the events in the dialog's handleEvent() method.

    class MyDialog extends Dialog
    private Button _okButton;
    public void MyDialog()
       ... initialization code...
        _okButton = new Button("OK");
        Panel panel = new Panel();
        ... more initialization code...
    public boolean action(Event event, Object arg)
        if (event.target == _okButton)
            System.out.println("The OK button was pressed");
        return super.action(event, arg);

  • Notice that in this case, the Dialog would need to make sure that the button generated the event before handling it. To do so, the dialog's action() method utilizes information contained in the event object. Let's take a closer look at the event object.

Previous Page | Next Page