i have a question on how to extends classes. i have three classes main, aaa, bbb classes.
i want to draw something in bbb class and print in main. for ex
main <-> aaa <-> bbb
but nothing is being print at output. if i draw something in main, or aaa than it works fine. any ideas's.

public class main extends JApplet
{
    aaa aaa_class = new aaa();

    ...

    public void paint(Graphics g)
    {
        super.paint(g); //redraw
        aaa_class.paint(g);
    }
}

aaa class--------------------

public class aaa 
{
    public levels()
    {

    }

    public void paint(Graphics g)
    {

    }
}

bbb classs-------------

public class bbb extends aaa
{   
    int x,y,width,height..etc

    public bbb()
    {
    }


    @Override
    public void paint(Graphics g)
    {
        g.fillRect(x,y,width,height);
        super.paint(g);
    }
}

Edited 3 Years Ago by hwoarang69

To use the paint method from bbb you need to create an an instance of the bbb class, eg change line 3 to

aaa aaa_class = new bbb(); // valid because bbb is a subclass of aaa
This question has already been answered. Start a new discussion instead.