The Notebook is a visual control which can contain 0 or more pages. Pages will usually be descendants of java.awt.Panel, but may be any descendant of java.awt.Component. The pages may be labeled with tabs to allow easy navigation by the user. The Notebook control can display itself using a Simple or Spiral style. Using the Simple style makes the notebook resemble a Windows 95 notebook control. In this style, the tabs may be placed on any side (Top, Bottom, Left or Right). Using the Spiral style makes the notebook resemble an OS/2 notebook control (spiral and all). Spiral notebooks allow for tabs on the Right or Bottom only.
This is an example (from the SAMPLES.ZIP file) of what a Simple notebook looks like:
This is an example (from the SAMPLES.ZIP file) of what a Spiral notebook looks like:
The tab location and notebook style may be changed at any time.
Since more than one page may belong to any given tab, the Spiral notebook style provides a status bar at the bottom with buttons for scrolling through the notebook pages. If there is more than one page per tab, an indication of the form Page x of y will be displayed. Note than when the Simple style is being used, only the first page of a tab can be accessed by the user. The additional pages may only be display programatically using the turnToPage() method.
Tabs may be any object. If a tab is an instance of java.awt.Image, it will be rendered as an image. Otherwise, the tab label's toString() method will be used to determine the text to display.
When there are more tabs than will fit in the tab area, one of two things will happen. If the notebook is using the Simple style and the tabs are on either the Top or Bottom, then multiple rows of tabs will automatically be generated. In all other style/tab location combinations, scroll buttons will appear to allow the user to scroll through the available tabs. A scroll button is visible in the bottom right corner of the Spiral example above.
There are four classes and two interfaces involved with implementing the Notebook class.
Notebook | This class represents the notebook and is the one which should be interacted with. |
NBRenderer | This interface defines the methods used by Notebook to render a "look" of a notebook. Mouse handling constants are also defined. |
NBSimpleLook | This class implements the NBRenderer interface to provide a simple notebook look which closely resembles Windows notebooks. |
NBSpiralLook | This class implements the NBRenderer interface to provide a spiral notebook look which closely resembles older OS/2 notebooks. |
PageVerifier | This interface defines the callback method which may be associated with a notebook page. The method may be called explicitly via the verifyPage() or turnToPage() methods or implicitly when the user changes notebook pages. |
HotSpot | This class is used by the Notebook class to manage its list of mouse hot spots. It may be used in the same manner for any custom control which has multiple mouse hot spots. |