package caltool; import caltool.model.CalendarTool; import caltool.view.CalendarToolUI; import mvp.*; /**** * * Class Main contains the main Java function for the Calendar system. It * constructs instances of the model, view, and process classes for the * Calendar and gives control to the view, which will manage communication with * the end user. *

* This is an initial implementation for GUI testing purposes, with no process * classes yet defined. * * @author Gene Fisher (gfisher@calpoly.edu) * @version 13apr15 * */ public class Main { /** * Construct models, construct views, compose views, and fire the puppy up. */ public static void main(String[] args) { mvp.Screen s; // The GUI screen CalendarTool calTool; // The top-level Calendar model CalendarToolUI calToolUI; // The top-level Calendar view /* * Construct the GUI screen, thereby initializing the GUI system. In * this Java-based implementation, the GUI screen is managed entirely * by the Java runtime environment, so the only thing to do in the way * of screen construction is to set its look and feel, if desired. In * other GUI toolkits, screen construction may involve more substantial * work. */ s = new mvp.Screen(); /* * Construct the top-level Calendar model. It will in turn construct * all subsidiary model classes and the data objects they require. * Note that the view parameter is null, since the view has not yet * been constructed. After it is, we call the calTool.setView method, * which is inherited from class Model. */ calTool = new CalendarTool(null); /* * Construct and compose the Calendar Tool view. Compose will lay out * all GUI components, including dialogs that appear during the course * of user interaction. */ calToolUI = new CalendarToolUI(s, calTool); calToolUI.compose(); /* * Store the view in the model to enable two-way communication between * the model and the view. */ calTool.setView(calToolUI); /* * Display the top-level view window on the UI screen. */ calToolUI.show(10,10); /* * In Java, no call to View.run is necessary, since showing any window * on the screen automatically starts the event loop. The program * subsequently exits when the System.exit function is called, e.g., * in response to the user choosing the File Quit menu item. */ } }