tags:

views:

32

answers:

2

i have a panel in another panel and i want to access an member of the child panel from the parent panel. The child panel reference that is in the parent panel doesn't see all the members that it has. Thanks! PS : the members i can't access are public

A: 

are you not able to call a getComponents() on the child panel and get all graphical members? If not, the question is not clear enough.

ring bearer
A: 

I made a little test and it works, but on my project doesn't. I think i make a mistake somewhere. Here is the test:

class Main
{
  public static void main(String[] arg)
  {
    MainPanel mp = new MainPanel();
    mp.fct();
  }
}

class MainPanel extends Panel
{
  SecondPanel sp;
  MainPanel()
  {
    sp = new SecondPanel();
  }
  void fct()
  {
    //the mainPanel can access member tf of second panel
    System.out.println(sp.tf.getText());
  }
}

class SecondPanel extends Panel
{
  TextField tf;
  SecondPanel()
  {
    tf = new TextField("Abcde");
    this.add(tf);
  }
}
Stefan
I discover where the mistake was...
Stefan
Reformatted code; revert if incorrect. Can you elaborate on the mistake?
trashgod