Ok, so I've been stuck for a little while now on this problem. I'm trying to pass an array of Tabs and I'm just not doing it correctly. I believe I'm missing something simple, because I need to learn more about what is happening with my code rather than just going through the motions.

Here's my code.

public class CountProg extends Canvas {
    private Tab[] incTabs;

    public CountProg()
    {
        super();
        //some code
       tabSet.addTab((Tab) getTabs()[0]);
    }


     public Tab[] getTabs()
    {
        return incTabs;
    }
    
    public void setTabs(Tab[] incTabs)
    {
            this.incTabs=incTabs;
        
    }
}
public class stCountTest extends CountProg {

    private StaffMain _sm;


    public stCountTest(StaffMain sm,String permission)
    {
        super();
        _sm=sm;
        
    
        setTabs(createTabs());
        init();
    }


     public Tab[] createTabs()
    { 
        Tab[] temp = new Tab[]{
        new Tab("One"),
        new Tab("Two"),
        new Tab("Three")
        };
        return temp;

    }

}

I know the problem is with my set and get methods but I just cant figure out precisely what it is.

If I create and array of tabs in the getTabs() method and return it, everything works fine.

I appreciate any help, thank you.

Well, i figured out my problem. It was pretty simple, I was calling the super class which setup my tabs in the constructor. Then I gave the tabs the information they needed to be set up. Kind of like putting the cart ahead of the horse.

I think my presentation of the problem was unclear. But anyway, i just took the tab setup code out of the constructor and made it it's own method, then when i setTabs() I also call the new method with the tab setup code. Well thanks all, and sorry about the ambiguity!

Edited 6 Years Ago by LReynolds: n/a

This question has already been answered. Start a new discussion instead.