AbstractPage is an abstract base class that provides functionality to defer populating a JPanel object until it is
actually viewed. This is very useful when using CardLayout and tab panel views which have several pages. Delaying the
construction means it will start up fast. Sometimes delay means never.
If subclasses choose to override any of the following methods, it is their responsibility to ensure their overridden
methods call the parent's method first. The methods are:
- public void paint (Graphics)
- public void paintComponents(Graphics)
- public void paintAll (Graphics)
- public void repaint ()
- public void repaint (long)
- public void repaint (int, int, int, int)
- public
void repaint (long, int, int, int, int)
- public void update (Graphics)
By default, if any of the methods is called, the panel will be populated. However user can setInvokeCondition() to
customize when the panel be populated. See javadoc of setInvokeContion() for details.
The idea of the lazy panel is from an article on JavaWorld at http://www.javaworld.com/javatips/jw-javatip90_p.html.
The credit should be given to Mark Roulo. We modified the code he provided in the article to add additional things as
we need. Things added are
- Added setInvokeCondition()
- Added addPageListener(), removePageListener() etc
so that subclass can fire
PageEvent