Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Deriving abstract class from non-abstract class

Reply
Thread Tools

Deriving abstract class from non-abstract class

 
 
Matthias Kaeppler
Guest
Posts: n/a
 
      05-22-2005
Hello,

I wonder if this is a flaw in my design:

In my program, I introduced an abstract class called VisualizationFrame
which inherits from javax.swing.JInternalFrame (which itself is not
abstract). The point to make it abstract was that it's supposed to be an
ABC by itself: Two other concrete classes, namely DiagramFrame and
StatisticsFrame inherit from it. They need to do special painting, so
this makes sense.

However, I want to force the two concrete classes to override the
paint() method, so I declared it abstract in VisualizationFrame.
Now this leads to some oddities so I have a couple of questions.

1. Since I changed the signature of paint() to be abstract now, will it
hide the superclass paint() method from JInternalFrame?

2. Both concrete classes need to implement the paint() method, but they
also need to call the base class paint() first, to actually draw the
window. But this method is abstract and has no body, so I would have to
call super.super.paint(), which is illegal.

Is that a flaw in my design? Should I simply make paint() in
VisualizationFrame non-abstract? This wouldn't express my intention as
clear, but it would be a lot simpler.

Cheers,
Matthias
 
Reply With Quote
 
 
 
 
R.F. Pels
Guest
Posts: n/a
 
      05-22-2005
Matthias Kaeppler wrote:

> However, I want to force the two concrete classes to override the
> paint() method, so I declared it abstract in VisualizationFrame.
> Now this leads to some oddities so I have a couple of questions.


Introduce a doPaint() method that is abstract, and call that from the
overridden paint() method in the ABC.

--
Ruurd
..o.
...o
ooo
 
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
what is the difference between abstract class and pure abstract class? skishorev@yahoo.co.in C++ 4 05-17-2006 08:07 AM
Re: Abstract Methods & Abstract Class Gerald Klix Python 1 10-20-2005 02:44 PM
Abstract Methods & Abstract Class Iyer, Prasad C Python 0 10-20-2005 06:35 AM
About abstract class and abstract method Sameer Java 4 08-31-2005 12:59 AM
Abstract class with no abstract functions Uzytkownik C++ 3 04-03-2005 05:45 PM



Advertisments