我想在主窗口textField 中写的消息,发送到子窗口的textArea中,并在子窗口textArea中显示我所输出的消息!
我试过在子窗中调用主窗口的方法!可是不知道怎么调用,本人刚学习java,希望哪个大侠能帮我分析一下,最好
能写个代码,在子窗口的类中怎样调用主窗口中的方法!!谢啦!!
我试过在子窗中调用主窗口的方法!可是不知道怎么调用,本人刚学习java,希望哪个大侠能帮我分析一下,最好
能写个代码,在子窗口的类中怎样调用主窗口中的方法!!谢啦!!
解决方案 »
- 求助!!!鼠标响应键盘不响应
- 五子棋(网络版)求帮助
- 关于会员的在线时长统计
- Applet问题:在applet中弹出一个新的ie! 谢谢 !请不吝赐教!
- 高手进:有关Ajax和Java Servlet的问题
- js里的document.write总是转到新的页面输出???
- 帮帮忙
- 我是个初学者,求一本学习JAVA的好书!(中文的)
- import的问题
- jrun 是不是Web server,它们之间何关系啊?可以代替apache的软件是什么 呢?
- 在下面的代码中怎么实现序号是从1开始,按顺序增加?
- 我写了一个程序是扫描在内网中所有的可用IP,可是,在my Eclipse中一运行就会死机!!!代码如下:::
具体代码你可以参考下import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;public class FatherFrame extends JFrame implements ActionListener {
private JButton btn=new JButton("click"); public JTextField getJtx() {
return jtx;
} private JTextField jtx=new JTextField(15);
private JDialog dialog=null; public FatherFrame(String title){
super(title);
Container c=this.getContentPane();
c.setLayout(new FlowLayout());
c.add(jtx);
c.add(btn);
btn.addActionListener(this);
this.pack();
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
} @Override
public void actionPerformed(ActionEvent e) {
dialog=new ChildDialog(this);// dialog.getParent();
} public static void main(String[] args) {
new FatherFrame("demo");
}
}
class ChildDialog extends JDialog{
private FatherFrame father=null;
private JLabel label=null;
private JTextArea jta=new JTextArea(); public ChildDialog(FatherFrame fatherFrame){
this.father=fatherFrame;
jta.setText(father.getJtx().getText());
label=new JLabel("以下是从父窗口获得的信息:");
this.getContentPane().setLayout(new FlowLayout());
this.getContentPane().add(label);
this.getContentPane().add(jta);
this.pack();
// this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
this.setLocationRelativeTo(null);
}
}