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);
    }
}

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

oh cool i didnt know we could do this. thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.