Re: How to let two JFrame contact each other?# Java - 爪哇娇娃
i*e
1 楼
It is simple. You can do it in many ways.
One way to do it is to pass your mainFrame to the event listener of
your Jbutton. Like this,
MyActionListener myactionhandler = new MyActionListener(mainFrame);
....
class MyActionListener extends ActionListener {
private textFrame;
public MyActionListener(JFrame f) {
textFrame = f;
}
public void actionPerformed(ActionEvent evt) {
//append text to textFrame here
}