This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with inheritance  RSS feed

 
Jules Chen
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone, I am having trouble with my swing program. I was given an abstract class, and i am trying to implement a subclass for it. The abstract class has two abstract methods that i must implement:
public abstract void createGUI();
public abstract void mousePressed(MouseEvent e);
So, this is what i have after deleting everything else to isolate the error that i have:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class FittsLawTester extends AbstractFittsLawTester implements
mouseListener {
public void mousePressed(MouseEvent e){}
public void createGUI(){}
}

And my error is this:
AbstractFittsLawTester(int) in hci_631_project1.AbstractFittsLawTester cannot be applied to ()
public class FittsLawTester extends AbstractFittsLawTester{
^
1 error

I'm just wonder what the problem is cause I can't figure it out. thanks for any help!
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what does the abstract class look like? Does it not have a no argument constructor? If not, then you have to specify which constructor to use from the subclass. Note that the first thing that any constructor does is to either invoke another constructor in the same class, or invoke a super class constructor. If you don't specify such an invocation, then the compiler adjusts things to invoke the super class no argument constructor. Also note that every class has a constructor. If you don't write one, the compiler will provide a no argument constructor that does one thing - invoke the super class no argument constructor.
Is this heading in the right direction for your problem?
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh and...
Welcome to JavaRanch, Jules Chen!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!