org.tbee.swing.cardlayout
Class CardLayout

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

public class CardLayout
extends 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 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(Component comp, String constraints)
           
 void addLayoutComponent(String name, Component comp)
           
protected  void fireCardChangedListenerEvent(CardChangeEvent e)
           
protected  void fireCardChangeListenerEvent(CardChangeEvent e)
          Fire an event
 Component getComponent(String name)
          Get the name of a component
 Container getContainer()
           
 String getName(Component comp)
          Get the name of a component
 Component getVisibleComponent()
          Get the currently visible component
 String getVisibleComponentName()
          Get the name of the currently visible component
 void layoutContainer(Container parent)
          hook in to get the container we're showing
 void removeCardChangedListener(CardChangedListener ccl)
           
 void removeCardChangeListener(CardChangeListener ccl)
          Remove a listener
 void removeLayoutComponent(Component comp)
           
 void show(Container parent, 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 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 Container getContainer()

addLayoutComponent

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

addLayoutComponent

public void addLayoutComponent(Component comp,
                               String constraints)
Parameters:
comp -
constraints -

removeLayoutComponent

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

layoutContainer

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

Specified by:
layoutContainer in interface LayoutManager
Overrides:
layoutContainer in class CardLayout

getVisibleComponent

public Component getVisibleComponent()
Get the currently visible component

Returns:

getVisibleComponentName

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

Returns:

getName

public String getName(Component comp)
Get the name of a component

Parameters:
comp -
Returns:

getComponent

public Component getComponent(String name)
Get the name of a component

Parameters:
comp -
Returns:

show

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

Overrides:
show in class 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 © 2011 KnowledgePlaza. All Rights Reserved.