Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Cruel intentions

Reply
Thread Tools

Cruel intentions

 
 
Larry Barowski
Guest
Posts: n/a
 
      06-16-2005

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> I am now most certainly confused! To me the whole advantage of OOP is
> code reuse, but from what I have read it seems that even trying to
> reuse an event handler for a JMenu is less than trival. If you make a
> change to the superclass e.g. add a new item on the help menu, you must
> go through and thoroughly test every subclass?


But there is almost always no good reason to reuse an event
handler. Superclasses and subclasses should handle events
separately. Note that the Swing component classes rarely
implement ActionListener. JComboBox does, but you'll see
the comment "This method is public as an implementation
side effect. do not call or override."

> The alternitve as Larry suggests is to use a specific (abstract) method
> to react to events, which confuses me further!


You would only make it abstract if subclassing is necessary
and the subclass "must" react to the event. More commonly,
you would allow listeners (your own class of listeners) to be
added to the parent. Either way, this allows the superclass to
change the internals of how these events are generated
without breaking subclasses.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
So cruel, so true SkepticalSteve@gmail.com NZ Computing 41 02-12-2007 12:43 AM
DVD Verdict reviews: THRILLER: A CRUEL PICTURE, MAYOR OF THE SUNSET STRIP, and more! DVD Verdict DVD Video 0 09-28-2004 09:08 AM
There's nothing customers can't break through good intentions. Woolly Mittens HTML 3 01-07-2004 09:34 PM



Advertisments