// Multi-Window interactions with JDialog to do "modal" interactions import java.io.*; // need this to do files import java.awt.*; // needed to get "Container" class below import java.awt.event.*; // event processing requirements import javax.swing.*; // we will use Swing... class multi_window_example extends JFrame implements ActionListener { JButton dialog, exit; multi_window_example() { setLocation(200,200); dialog = new JButton("Open"); exit = new JButton("Exit"); Container c = getContentPane(); c.setLayout(new GridLayout(3,1)); c.add(dialog); c.add(exit); dialog.addActionListener(this); exit.addActionListener(this); } public void actionPerformed (ActionEvent e) { if (e.getSource() == exit) { setVisible(false); System.exit(0); } if (e.getSource() == dialog) { InputForm inf = new InputForm(this); inf.setVisible(true); if ( inf.getStatus() == InputForm.CANCELLED) JOptionPane.showMessageDialog(this, "Cancelled", "foobar", JOptionPane.PLAIN_MESSAGE); else JOptionPane.showMessageDialog(this, "Name: " + inf.getStudentName() + " SSN: " + inf.getSSN() + " AGE: " + inf.getAge(), "Information from Inputform", JOptionPane.PLAIN_MESSAGE); } } public static void main (String args[]) { multi_window_example application = new multi_window_example(); application.setSize(200,200); application.setVisible(true); } }