1  import java.io.IOException;
  2  import javax.swing.JFrame;
  3  import javax.swing.JOptionPane;
  4  
  5  /**
  6     A graphical simulation of an automatic teller machine
  7  */
  8  public class ATMViewer
  9  {  
 10     public static void main(String[] args)
 11           throws IOException, ClassNotFoundException
 12     {  
 13        if (args.length == 0)
 14        {   
 15           JOptionPane.showMessageDialog(null, 
 16                 "Usage: ATMViewer propertiesFile");
 17           return;
 18        }
 19        else 
 20        {
 21           try
 22           {
 23              SimpleDataSource.init(args[0]);            
 24           }
 25           catch (IOException exception)
 26           {
 27              JOptionPane.showMessageDialog(null, 
 28                    "Can't connect to database");
 29              return;
 30           }
 31           catch (ClassNotFoundException exception)
 32           {
 33              JOptionPane.showMessageDialog(null, 
 34                    "Can't connect to database");
 35              return;
 36           }
 37        }
 38  
 39        ATM theATM;
 40  
 41        Bank theBank = new Bank();
 42        theATM = new ATM(theBank);
 43  
 44        JFrame frame = new ATMFrame(theATM);
 45        frame.setTitle("First National Bank of Java");      
 46        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 47        frame.setVisible(true);
 48     }
 49  }
 50