Constructing the main window

In the constructor of class FrmMain mainly three steps are done

Once above steps are through as described below, application SimplyHTML's main window is shown. Once shown, the start process of the application has ended and control is transferred to the event dispatching thread which Java created for SimplyHTML automatically.

The event dispatching thread controls the program flow by invoking methods attached to certain events, which usually are fired by user actions.

Preparing for window close events

Closing an ordinary window might or might not need special handling. In the simplest case, respective window just closes which would be done automatically. For an application's main window however, closing usually terminates the application which in turn mostly requires certain cleanup before an application actually can be terminated.

A window can be closed through various actions such as the user selecting 'Exit' from menu 'File' or the user likes to switch off the computer etc. Most of such actions are signaled to a JFrame, if it claims to receive respective event notifications.

In class FrmMain, method enableEvents is called in the constructor of the class for this. Method enableEvents is inherited from class Component of package java.awt and is called, when a subclass of Component likes to receive or handle events of a certain type even without a respective event listener in place.

Class FrmMain calls for events defined in AWTEvent.WINDOW_EVENT_MASK and causes events of this type being delivered to method processWindowEvent of class FrmMain. This method handles window closing events for the main window of application SimplyHTML.

Especially see ' Avoiding loss of data in the close process' partly dealing with this topic too.