import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;class test extends Frame implements ActionListener
{
Button b = new Button("click");
JDialog dialog = new JDialog();
Button click = new Button("click");
TextField tf = new TextField(10);
public void display()
{
this.add(b);
b.addActionListener(this);
setSize(200,200);
setVisible(true);
}
public static void main(String str[])
{
test t = new test();
t.display();
} public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b)
{
click.addActionListener(this);
dialog.getContentPane().add(click,BorderLayout.NORTH);
dialog.getContentPane().add(tf);
dialog.show();
}
else
{
System.out.println (tf.getText());
}
}
}能打出来也能返回到主窗体;
import java.awt.event.*;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;class test extends Frame implements ActionListener
{
Button b = new Button("click");
JDialog dialog = new JDialog();
Button click = new Button("click");
TextField tf = new TextField(10);
public void display()
{
this.add(b);
b.addActionListener(this);
setSize(200,200);
setVisible(true);
}
public static void main(String str[])
{
test t = new test();
t.display();
} public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b)
{
click.addActionListener(this);
dialog.getContentPane().add(click,BorderLayout.NORTH);
dialog.getContentPane().add(tf);
dialog.show();
}
else
{
System.out.println (tf.getText());
}
}
}能打出来也能返回到主窗体;
或者,在JDialog的处理按钮事件中,修改
主截面中对应的值就可以了,在主截面的
构造函数上要注意一下,最好有两个构造函数
一个对界面控件的初始化,一个为空只是为了
处理这个参数的传递。
{
return 文本.getText()
}
{
return txtName.getText ()
}
window.parent.document.all……,
这不就是父窗体的东西了吗?
难道这样实现不了?