package caltool.view; import mvp.*; import java.awt.*; public class CalendarToolWindow extends View { public CalendarToolWindow(Screen screen, Model model, CalendarToolUI calToolUI) { super(screen, model); this.calToolUI = calToolUI; /* * Normally the window is not allocated until the compose method, but * since the reason for this class' existence is to be a window, it's * allocated here in the constructor. Also, we need the window now so * we can attach the event listener to it in a common place, without * requiring that subclass compose methods call this.compose * explicitly. */ window = new mvp.Window(); window.addWindowListener(new CalendarToolWindowAdapter(this)); } /** * Show this' window. If it's the first time being displayed, show * relative to the top-level menubar. Otherwise, show at the last place * shown. */ public void show() { if (firstShowing) { firstShowing = false; Component rootWindow = calToolUI.getWindow(); super.show(rootWindow.getX(), rootWindow.getY() + rootWindow.getHeight() + 10); } else { super.show(); } } /** The parent caltool UI */ protected CalendarToolUI calToolUI; /** True only before the window is shown for the first time */ boolean firstShowing = true; }