0

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

Stefan
  • 237
  • 1
  • 3
  • 9
  • 2
    I have no idea what you mean by "The child panel reference that is in the parent panel doesn't see all the members that it has." Can you give an example? – Michael Mrozek Apr 13 '10 at 16:44

2 Answers2

0

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
  • 20,383
  • 7
  • 59
  • 72
0

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);
  }
}
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
Stefan
  • 237
  • 1
  • 3
  • 9