4.2. Managing the Main Window

As explained in Section 10.4, “Special Characteristics of AJAX Applications”, an AJAX web application usually runs in a single "web page" in a browser window. The page is generally not reloaded after it is opened initially, but it communicates user interaction with the server through AJAX communications. A window in an AJAX application is therefore more like a window in a desktop application and less like a web page.

A Window is the top-level container of a user interface displayed in a browser window. As an AJAX application typically runs on a single "page" (URL), there is usually just one window -- the main window. The main window can be accessed using the URL of the application. You set the main window with the setMainWindow() method of the Application class.

import com.itmill.toolkit.ui.*;

public class HelloWorld extends com.itmill.toolkit.Application {
    public void init() { 
        Window main = new Window("The Main Window"); 
        setMainWindow(main);

        ... fill the main window with components ...
    }
}

IT Mill Toolkit has two basic kinds of windows: application-level windows, such as the main window, and child windows inside the application-level windows. The child windows are covered in the next section, while application-level windows are covered in Section 10.1, “Application-Level Windows”.