Java 两个窗口间的传值
package jav;import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
public class ja9 {
public static void main(String[] args) {
Myframe mf = new Myframe();
mf.setBounds(500, 400, 300, 200);
mf.setVisible(true);
mf.setLayout(new FlowLayout());
JButton bu = new JButton("确定");
mf.add(bu);
bu.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
Myframe ff=new Myframe();
ff.setBounds(500, 450, 200, 100);
ff.setVisible(true);
ff.setLayout(new FlowLayout());
JLabel la=new JLabel("请输入一个批号");
JTextField tx=new JTextField(10);
JButton bn=new JButton("确定");
ff.add(la);
ff.add(tx);
ff.add(bn);
bn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
//mf.mm =tx.getText();
}
});
}
});
}
}
class Myframe extends JFrame {
public static String mm;
}