Deriving abstract class from non-abstract class

Discussion in 'Java' started by Matthias Kaeppler, May 22, 2005.

  1. 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
    Matthias Kaeppler, May 22, 2005
    #1
    1. Advertising

  2. Matthias Kaeppler

    R.F. Pels Guest

    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
    R.F. Pels, May 22, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sameer
    Replies:
    4
    Views:
    574
    Roedy Green
    Aug 31, 2005
  2. Uzytkownik
    Replies:
    3
    Views:
    580
    Uzytkownik
    Apr 3, 2005
  3. Replies:
    4
    Views:
    802
    Rolf Magnus
    May 17, 2006
  4. markww
    Replies:
    1
    Views:
    291
    Ivan Vecerina
    Aug 22, 2006
  5. Chris Zopers

    Abstract method in non-abstract class

    Chris Zopers, Aug 8, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    362
    Göran Andersson
    Aug 8, 2008
Loading...

Share This Page