Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Emily Diaz   on Jun 25 In Java Category.

  
Question Answered By: Joseph Evans   on Jun 25

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

Share: 

 
 
Didn't find what you were looking for? Find more on panel communication Or get search suggestion and latest updates.


Tagged: