
// Copyright (c) 2001 
package uk.co.patrickhaston.mars;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * Mars.MarsApplication
 * <P>
 * @author Patrick Haston
 */
public class MarsApplication 
{
  public static MarsApplication theApp;
  public static MarsFrame frame;

  /**
   * Constructor
   */
  public MarsApplication() 
  {
  }

  public void init()
  {
    frame = new MarsFrame(this);
    //Center the window
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = frame.getSize();
    if (frameSize.height > screenSize.height) 
    {
      frameSize.height = screenSize.height;
    }
    if (frameSize.width > screenSize.width) 
    {
      frameSize.width = screenSize.width;
    }
    frame.setLocation((screenSize.width - frameSize.width)/2, (screenSize.height - frameSize.height)/2);
    frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } });
    frame.setVisible(true);
    frame.startFrame.toFront();
  }

  /**
   * main
   * @param args
   */
  public static void main(String[] args) 
  {
    try  
    {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }
    catch (Exception e) 
    {
      e.printStackTrace();
    }
    theApp = new MarsApplication();
    theApp.init();
  }
}

 
