org.tbee.swing.cardlayout
Class CardLayout

java.lang.Object
  extended by java.awt.CardLayout
      extended by org.tbee.swing.cardlayout.CardLayout
All Implemented Interfaces:
java.awt.LayoutManager, java.awt.LayoutManager2, java.io.Serializable
Direct Known Subclasses:
AnimatedCardLayout

public class CardLayout
extends java.awt.CardLayout

A extension to CardLayout that can return a component's name.

Furthermore it adds a CardChangeEvent so components can react when they are shown. This is especially useful for implementing loading-on-demand:
- the regular "updateCard" method is reduced to a just-store-all-I-need-to-know-to-refresh
- a second "updateCardDelayed" method is added where, based on the stored data, the card is updated
- the card registers itself to the CardLayout and listens for CardChangeEvents
- is the "now visible" component in an event equal to the card, the updateCardDelayed method should be called.
- Note: at the end of the "updateCard" method, it should check if the card is already visible.
If so, "updateCardDelayed" should be called immediately (since the card is already visible, there will be no event)!

Version:
$Revision: 1.12 $
See Also:
Serialized Form

Field Summary
static java.lang.String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
Constructor Summary
CardLayout()
           
CardLayout(int hgap, int vgap)
           
 
Method Summary
 void addCardChangedListener(CardChangedListener ccl)
          Add a listener
 void addCardChangeListener(CardChangeListener ccl)
          Add a listener
 void addLayoutComponent(java.awt.Component comp, java.lang.String constraints)
           
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
           
protected  void fireCardChangedListenerEvent(CardChangeEvent e)
           
protected  void fireCardChangeListenerEvent(CardChangeEvent e)
          Fire an event
 java.awt.Component getComponent(java.lang.String name)
          Get the name of a component
 java.awt.Container getContainer()
           
 java.lang.String getName(java.awt.Component comp)
          Get the name of a component
 java.awt.Component getVisibleComponent()
          Get the currently visible component
 java.lang.String getVisibleComponentName()
          Get the name of the currently visible component
 void layoutContainer(java.awt.Container parent)
          hook in to get the container we're showing
 void removeCardChangedListener(CardChangedListener ccl)
           
 void removeCardChangeListener(CardChangeListener ccl)
          Remove a listener
 void removeLayoutComponent(java.awt.Component comp)
           
 void show(java.awt.Container parent, java.lang.String name)
          This method is overriden to provide the hook-in for the event listeners
 
Methods inherited from class java.awt.CardLayout
addLayoutComponent, first, getHgap, getLayoutAlignmentX, getLayoutAlignmentY, getVgap, invalidateLayout, last, maximumLayoutSize, minimumLayoutSize, next, preferredLayoutSize, previous, setHgap, setVgap, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SOURCECODE_VERSION

public static final java.lang.String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values
Constructor Detail

CardLayout

public CardLayout()

CardLayout

public CardLayout(int hgap,
                  int vgap)
Parameters:
hgap -
vgap -
Method Detail

getContainer

public java.awt.Container getContainer()

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Specified by:
addLayoutComponent in interface java.awt.LayoutManager
Overrides:
addLayoutComponent in class java.awt.CardLayout
Parameters:
name -
comp -

addLayoutComponent

public void addLayoutComponent(java.awt.Component comp,
                               java.lang.String constraints)
Parameters:
comp -
constraints -

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Specified by:
removeLayoutComponent in interface java.awt.LayoutManager
Overrides:
removeLayoutComponent in class java.awt.CardLayout

layoutContainer

public void layoutContainer(java.awt.Container parent)
hook in to get the container we're showing

Specified by:
layoutContainer in interface java.awt.LayoutManager
Overrides:
layoutContainer in class java.awt.CardLayout

getVisibleComponent

public java.awt.Component getVisibleComponent()
Get the currently visible component

Returns:

getVisibleComponentName

public java.lang.String getVisibleComponentName()
Get the name of the currently visible component

Returns:

getName

public java.lang.String getName(java.awt.Component comp)
Get the name of a component

Parameters:
comp -
Returns:

getComponent

public java.awt.Component getComponent(java.lang.String name)
Get the name of a component

Parameters:
comp -
Returns:

show

public void show(java.awt.Container parent,
                 java.lang.String name)
This method is overriden to provide the hook-in for the event listeners

Overrides:
show in class java.awt.CardLayout

addCardChangeListener

public void addCardChangeListener(CardChangeListener ccl)
Add a listener

Parameters:
ccl -

removeCardChangeListener

public void removeCardChangeListener(CardChangeListener ccl)
Remove a listener

Parameters:
ccl -

fireCardChangeListenerEvent

protected void fireCardChangeListenerEvent(CardChangeEvent e)
Fire an event

Parameters:
e -

addCardChangedListener

public void addCardChangedListener(CardChangedListener ccl)
Add a listener

Parameters:
ccl -

removeCardChangedListener

public void removeCardChangedListener(CardChangedListener ccl)

fireCardChangedListenerEvent

protected void fireCardChangedListenerEvent(CardChangeEvent e)


Copyright © 2010 KnowledgePlaza. All Rights Reserved.