Package com.jidesoft.dialog
Class AbstractPage
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- com.jidesoft.dialog.AbstractPage
-
- All Implemented Interfaces:
Laziness
,java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
- Direct Known Subclasses:
AbstractDialogPage
public abstract class AbstractPage extends javax.swing.JPanel implements Laziness
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)
- Added setInvokeCondition()
- Added addPageListener(), removePageListener() etc
so that subclass can fire
PageEvent
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description protected PageEvent
_pageEvent
Only oneDataChangeEvent
is needed per model instance since the event's only (read-only) state is the source property.static int
INVOKE_ON_ALL
Used by setInvokeCondition().static int
INVOKE_ON_NONE
Used by setInvokeCondition().static int
INVOKE_ON_PAINT
Used by setInvokeCondition().static int
INVOKE_ON_REPAINT
Used by setInvokeCondition().static int
INVOKE_ON_UPDATE
Used by setInvokeCondition().static int
INVOKE_ON_VALIDATE
Used by setInvokeCondition().-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractPage()
Creates an AbstractPage.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPageListener(PageListener l)
Adds aPageListener
to the page.boolean
allowClosing()
Allow this document closing.void
firePageEvent(int id)
Runs eachPageListener
'spageEventFired
method.void
firePageEvent(java.lang.Object source, int id)
Runs eachPageListener
'spageEventFired
method.int
getInvokeCondition()
Gets the invoke condition.PageListener[]
getPageListeners()
Returns an array of all thePageListener
s added to thisPage
withaddPageListener
.void
initialize()
Force the lazyInitialize() method implemented in the child class to be called.void
invalidate()
void
paint(java.awt.Graphics g)
void
paintAll(java.awt.Graphics g)
void
paintComponents(java.awt.Graphics g)
void
removePageListener(PageListener l)
Removes aPageListener
from the page.void
repaint()
void
repaint(int i1, int i2, int i3, int i4)
void
repaint(long l)
void
repaint(long l, int i1, int i2, int i3, int i4)
void
reset()
Resets the page which will result all child components being removed and the methodinitialize()
being invoked again.void
revalidate()
void
setAllowClosing(boolean allowClosing)
Sets allow closing.void
setInvokeCondition(int invokeCondition)
Sets the invoke condition.void
update(java.awt.Graphics g)
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.jidesoft.dialog.Laziness
lazyInitialize
-
-
-
-
Field Detail
-
INVOKE_ON_ALL
public static int INVOKE_ON_ALL
Used by setInvokeCondition(). This value means initialize will be called in all paint/repaint/update methods.
-
INVOKE_ON_NONE
public static int INVOKE_ON_NONE
Used by setInvokeCondition(). This value means initialize will not be called. You have to call it manually.
-
INVOKE_ON_PAINT
public static int INVOKE_ON_PAINT
Used by setInvokeCondition(). This value means initialize will be called with paint() is called.
-
INVOKE_ON_REPAINT
public static int INVOKE_ON_REPAINT
Used by setInvokeCondition(). This value means initialize will be called with repaint() is called.
-
INVOKE_ON_UPDATE
public static int INVOKE_ON_UPDATE
Used by setInvokeCondition(). This value means initialize will be called with update() is called.
-
INVOKE_ON_VALIDATE
public static int INVOKE_ON_VALIDATE
Used by setInvokeCondition(). This value means initialize will be called with invalidate(), revalidate() is called.
-
_pageEvent
protected transient PageEvent _pageEvent
Only oneDataChangeEvent
is needed per model instance since the event's only (read-only) state is the source property. The source of events generated here is always "this".
-
-
Method Detail
-
getInvokeCondition
public int getInvokeCondition()
Gets the invoke condition. Invoke condition defines how lazy the page is. By default, the lazyInitialize() will be called on any update, paint or repaint method. However you can change the invoke condition to INVOKE_ON_PAINT. If so, lazyInitialize() will be called only when paint() method is called. You can even set the invoke condition to INVOKE_ON_NONE. If so, you will be responsible to call lazyInitialize() since none of those methods methods mentioned above will call lazyInitialize().- Returns:
- the invocation condition
-
setInvokeCondition
public void setInvokeCondition(int invokeCondition)
Sets the invoke condition.- Parameters:
invokeCondition
- the invoke condition.
-
invalidate
public void invalidate()
- Overrides:
invalidate
in classjava.awt.Container
-
revalidate
public void revalidate()
- Overrides:
revalidate
in classjavax.swing.JComponent
-
paint
public void paint(java.awt.Graphics g)
- Overrides:
paint
in classjavax.swing.JComponent
-
paintAll
public void paintAll(java.awt.Graphics g)
- Overrides:
paintAll
in classjava.awt.Component
-
paintComponents
public void paintComponents(java.awt.Graphics g)
- Overrides:
paintComponents
in classjava.awt.Container
-
repaint
public void repaint()
- Overrides:
repaint
in classjava.awt.Component
-
repaint
public void repaint(long l)
- Overrides:
repaint
in classjava.awt.Component
-
repaint
public void repaint(int i1, int i2, int i3, int i4)
- Overrides:
repaint
in classjava.awt.Component
-
repaint
public void repaint(long l, int i1, int i2, int i3, int i4)
- Overrides:
repaint
in classjavax.swing.JComponent
-
update
public void update(java.awt.Graphics g)
- Overrides:
update
in classjavax.swing.JComponent
-
initialize
public final void initialize()
Force the lazyInitialize() method implemented in the child class to be called. If this method is called more than once on a given object, all calls but the first do nothing.
-
reset
public void reset()
Resets the page which will result all child components being removed and the methodinitialize()
being invoked again.- Since:
- 3.2.2
-
addPageListener
public void addPageListener(PageListener l)
Adds aPageListener
to the page.- Parameters:
l
- thePageListener
to be added
-
removePageListener
public void removePageListener(PageListener l)
Removes aPageListener
from the page.- Parameters:
l
- thePageListener
to be removed
-
getPageListeners
public PageListener[] getPageListeners()
Returns an array of all thePageListener
s added to thisPage
withaddPageListener
.- Returns:
- all of the
PageListener
s added, or an empty array if no listeners have been added
-
firePageEvent
public void firePageEvent(int id)
Runs eachPageListener
'spageEventFired
method.- Parameters:
id
- event id.
-
firePageEvent
public void firePageEvent(java.lang.Object source, int id)
Runs eachPageListener
'spageEventFired
method.- Parameters:
source
- of this eventid
- event id.
-
setAllowClosing
public void setAllowClosing(boolean allowClosing)
Sets allow closing. If true, the document cannot be closed. user can change the value in documentClosing() to prevent document from being closed.- Parameters:
allowClosing
- true or false.
-
allowClosing
public boolean allowClosing()
Allow this document closing. By default it return true. User can override this method to return based on condition. A typical user case is: add a DocumentComponentListener. In documentComponentClosing, make this method return to false to prevent it from being closed.- Returns:
- whether allow closing
-
-