Deriving abstract class from non-abstract class

M

Matthias Kaeppler

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
 
R

R.F. Pels

Matthias said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top