Results 1 to 8 of 8

Thread: Event Hierarchy

  1. #1

    Thread Starter
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Event Hierarchy

    I think the event hierarchy is a bit too much on the Everything Is A Class bandwagon. It could better be implemented like MS.

    Any opinions?

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  2. #2
    Everything's class-happy in Java.

  3. #3
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Not quite sure what you mean. Are you talking about the
    java.awt.event classes? The adapter classes, listeners, and the event classes?

  4. #4

    Thread Starter
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    Exactly.

    If I create a class in VB and want to associate some events with it, I just need to create a public event procedure and I am done.

    If I want to trap an object's events in my code, I need to write the procedure declared as public event handler inside the object in my code.

    But look at Java. You need to create a class that implements a listener, then you have to override all the methods inside that listener, whether or not you need those events, and finally register it with the class which will receive the events. SO much work!

    Mind ya, I am trying to get something out in favour of Java by criticizing it. Just my way of knowing things better.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  5. #5
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    It really matters what kind of event you are trying to trap.
    Low level events or semantic events "high level". I noramlly dont use a listener for low level events because of the need to provide multiple method implemations. It just doesnt make sense unless you are trapping multiple events. I do use listeners for high level events like ActionListener,AdjustmentListener,ItemListener, TextListener because there is only one method defined for each listener. For low level events i use adapter classes this way i just have to override the nessary method needed.


    For instance...... say if you want test for window closing events on a JFrame. You can either implement a WindowListener interface or extend "subclass" the WindowAdapter class. If you
    implemented the WindowListener interface then you would have to provided a method signature in your class for seven methods
    which would be a pain in the A@#.

  6. #6

    Thread Starter
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    I look at it this way:

    In VB when I have to trap a particular event for an object, all I do is write a public sub (sort of overriding) for that event as specified by the object.

    In Java, even if I want to trap the existing events, I have to go create a listener, register it and then override all its methods, as you pointed out.

    Couldn't Java implement events the way MS did/does? And if not, why?

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  7. #7
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    If you extend or "subclass" an adapter class then
    all you have to do is override the necessary method.
    For high level events it really doesnt make a diffrence if you implement a listener or subclass an adapter class because
    of the small amount of events that you can trap. Java is true
    OOP so obviously the creation of a subprocedure wouldnt make sense in terms of trying to mimic Visual Basic. I dont know i dont
    see it as being much work to trap events in Java.

  8. #8

    Thread Starter
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    Yes, the OOP has been very strictly (I would say a little too strictly) implemented in Java.

    It's both an advantage and a disadvantage. From VB point of view, it's just a bit complicated to get used to, while from an OOP point of view, it's just the logical way to go.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width