Panel 2 needs a reference to panel 1. Thus, you could pass panel1 as an
argument to the contructor of panel2:
public class Panel2 extends Panel{
private Panel panel1;
public Panel2(Panel panel1){
this.panel1 = panel1;
}
}
And then panel1 should include some method for setting the value of the
text field, so that panel2 can do:
button = new Button();
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
panel1.setText1("New text");
}
});