JAVA对话框事件
import java.awt.*; import java.awt.event.*; import java.awt.Container; import javax.swing.*; public class JAidalogDemo2 { public static void main(String[] args) { JAidalogDemo2 jAidalogDemo2=new JAidalogDemo2(); } private JTextField text; public JDialog dialog; public JAidalogDemo2() { JFrame frame=new JFrame("主窗口"); Container contentPane=frame.getContentPane(); JButton button=new JButton("显示数据"); button.addActionListener(new ActionListenerImp()); contentPane.add(button,BorderLayout.WEST); text=new JTextField("填写数据处"); contentPane.add(text,BorderLayout.CENTER); frame.setVisible(true); } private class ActionListenerImp implements ActionListener { public void actionPerformed(ActionEvent e) { JFrame dialog=new JFrame("显示数据窗口"); Container contentPane=dialog.getContentPane(); JLabel label= new JLabel(text.getText(),JLabel.CENTER); contentPane.add(label); dialog.setVisible(true); } } }