echopointng.tabbedpane
Class DefaultTabModel

java.lang.Object
  extended by echopointng.tabbedpane.AbstractTabModel
      extended by echopointng.tabbedpane.DefaultTabModel
All Implemented Interfaces:
TabModel, java.io.Serializable

public class DefaultTabModel
extends AbstractTabModel
implements java.io.Serializable

DefaultTabModel holds its content component references in memory (and hence does no lazy loading of tab content)

It also does not release tab information unless intructed to do so by the removeTabAt() method.

If no font or color information is passed in when a tab is created, then the current colors and fonts of this model will be used later when the getTabTitleAt() method is called.

See Also:
Serialized Form

Nested Class Summary
 class DefaultTabModel.TabButton
          TabModelButton is a ButtonEx that is linked to the TabModel and hence is told the tab selection state that it should reflect in its colors and fonts etc.. by the TabModel.
 
Field Summary
static Color DEFAULT_BACKGROUND
           
static Border DEFAULT_BORDER
           
static Font DEFAULT_FONT
           
static Color DEFAULT_FOREGROUND
           
static Color DEFAULT_ROLLOVER_BACKGROUND
           
static Border DEFAULT_ROLLOVER_BORDER
           
static Font DEFAULT_ROLLOVER_FONT
           
static Color DEFAULT_ROLLOVER_FOREGROUND
           
static Color DEFAULT_SELECTED_BACKGROUND
           
static Border DEFAULT_SELECTED_BORDER
           
static Font DEFAULT_SELECTED_FONT
           
static Color DEFAULT_SELECTED_FOREGROUND
           
static Color DEFAULT_SELECTED_ROLLOVER_BACKGROUND
           
static Border DEFAULT_SELECTED_ROLLOVER_BORDER
           
static Font DEFAULT_SELECTED_ROLLOVER_FONT
           
static Color DEFAULT_SELECTED_ROLLOVER_FOREGROUND
           
 
Fields inherited from class echopointng.tabbedpane.AbstractTabModel
changeEvent, listenerList, tabImageRenderer
 
Constructor Summary
DefaultTabModel()
          Constructs a DefaultTabModel
 
Method Summary
 void addTab(Component tabComponent, Component tabContent)
          Adds a new tab to the end of the collection of tabs.
 void addTab(ImageReference icon, Component tabContent)
          Adds a new tab with the specified icon.
 void addTab(java.lang.String tabTitle, Component tabContent)
          Adds a new tab with the specified title.
 void addTab(java.lang.String tabTitle, ImageReference icon, Component tabContent)
          Adds a new tab with the specified title and icon.
 Color getBackground()
           
 Border getBorder()
           
 Font getFont()
           
 Color getForeground()
           
 Color getRolloverBackground()
           
 Border getRolloverBorder()
           
 Font getRolloverFont()
           
 Color getRolloverForeground()
           
 Color getSelectedBackground()
           
 Border getSelectedBorder()
           
 Font getSelectedFont()
           
 Color getSelectedForeground()
           
 Color getSelectedRolloverBackground()
           
 Border getSelectedRolloverBorder()
           
 Font getSelectedRolloverFont()
           
 Color getSelectedRolloverForeground()
           
 Component getTabAt(int index, boolean isSelected)
          This is called to retrieve a Component that represents the title of the tab at the specified index.
 Component getTabContentAt(int index)
          This is called to retrieve the Component that represents the contents of the tab at the specified index.
 int indexOfTab(Component tabComponent)
          This is called to return the index of the component that makes up a tab.
 void insertTab(int index, Component tabComponent, Component tabContent)
          Called to insert a new tab at the specified index.
 void insertTab(int index, java.lang.String tabTitle, ImageReference icon, Component tabContent)
          Called to insert a new tab at the specified index.
 void releaseTabAt(int index)
          Does nothing as all tabs are kept in memory once added to this TabModel implementation.
 void removeTabAt(int index)
          Removes the tab details at the specified index
 void setBackground(Color background)
          Sets the background color to be used on non selected tabs
 void setBorder(Border border)
           
 void setFont(Font font)
          Sets the font to be used on non selected tabs
 void setForeground(Color foreground)
          Sets the foreground color to be used on non selected tabs
 void setRolloverBackground(Color rolloverBackground)
          Sets the background color to use on tab rollover
 void setRolloverBorder(Border rolloverBorder)
           
 void setRolloverFont(Font rolloverFont)
          Sets the font to use on tab rollover
 void setRolloverForeground(Color rolloverForeground)
          Set the foreground color to use on tab rollover
 void setSelectedBackground(Color selectedBackground)
          Sets the background color to be used on selected tabs
 void setSelectedBorder(Border selectedBorder)
           
 void setSelectedFont(Font selectedFont)
          Sets the font to be used on selected tabs
 void setSelectedForeground(Color selectedForeground)
          Sets the foreground color to be used on selected tabs
 void setSelectedRolloverBackground(Color selectedRolloverBackground)
          Sets the background color to use on rollover of selected tabs
 void setSelectedRolloverBorder(Border selectedRolloverBorder)
           
 void setSelectedRolloverFont(Font selectedRolloverFont)
          Sets the font to use on rollover of selected tabs
 void setSelectedRolloverForeground(Color selectedRolloverForeground)
          Sets the foreground color to use on rollover of selected tabs
 int size()
          This is called to return how many tabs are returned by this TabModel.
 
Methods inherited from class echopointng.tabbedpane.AbstractTabModel
addChangeListener, fireStateChanged, getTabImageRenderer, removeChangeListener, setTabImageRenderer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SELECTED_BACKGROUND

public static final Color DEFAULT_SELECTED_BACKGROUND

DEFAULT_SELECTED_FOREGROUND

public static final Color DEFAULT_SELECTED_FOREGROUND

DEFAULT_SELECTED_FONT

public static final Font DEFAULT_SELECTED_FONT

DEFAULT_SELECTED_BORDER

public static final Border DEFAULT_SELECTED_BORDER

DEFAULT_SELECTED_ROLLOVER_BACKGROUND

public static final Color DEFAULT_SELECTED_ROLLOVER_BACKGROUND

DEFAULT_SELECTED_ROLLOVER_FOREGROUND

public static final Color DEFAULT_SELECTED_ROLLOVER_FOREGROUND

DEFAULT_SELECTED_ROLLOVER_FONT

public static final Font DEFAULT_SELECTED_ROLLOVER_FONT

DEFAULT_SELECTED_ROLLOVER_BORDER

public static final Border DEFAULT_SELECTED_ROLLOVER_BORDER

DEFAULT_BACKGROUND

public static final Color DEFAULT_BACKGROUND

DEFAULT_FOREGROUND

public static final Color DEFAULT_FOREGROUND

DEFAULT_FONT

public static final Font DEFAULT_FONT

DEFAULT_BORDER

public static final Border DEFAULT_BORDER

DEFAULT_ROLLOVER_BACKGROUND

public static final Color DEFAULT_ROLLOVER_BACKGROUND

DEFAULT_ROLLOVER_FOREGROUND

public static final Color DEFAULT_ROLLOVER_FOREGROUND

DEFAULT_ROLLOVER_FONT

public static final Font DEFAULT_ROLLOVER_FONT

DEFAULT_ROLLOVER_BORDER

public static final Border DEFAULT_ROLLOVER_BORDER
Constructor Detail

DefaultTabModel

public DefaultTabModel()
Constructs a DefaultTabModel

Method Detail

size

public int size()
Description copied from interface: TabModel
This is called to return how many tabs are returned by this TabModel.

Specified by:
size in interface TabModel
Returns:
an int greater than 0
See Also:
TabModel.size()

getTabAt

public Component getTabAt(int index,
                          boolean isSelected)
Description copied from interface: TabModel
This is called to retrieve a Component that represents the title of the tab at the specified index.

The returned Component must be unique since it will become a child of the TabbedPane so it can be fully rendered.

If the returned Component has ActionListeners, such as a ButtonEx, then the parent TabbedPane wil attach itself so it can know when the Tab is pressed and hence has become selected. If not then it is the responbility of the component to inform that TabbedPane of the events that may affect tab selection.

This method may be called at any time and does not support lazy loading of the tabs (since it makes no sense as they must all be visible in order to select one).

Specified by:
getTabAt in interface TabModel
Parameters:
index - - the index of the tab
isSelected - - true if the index is the current selected tab index.
Returns:
- the component of the tab at index or null if there isnt a component at that index
See Also:
TabModel.getTabAt(int, boolean)

getTabContentAt

public Component getTabContentAt(int index)
Description copied from interface: TabModel
This is called to retrieve the Component that represents the contents of the tab at the specified index. This is designed to be lazy loaded, and hence will not be called until absolutely needed.

However once it has been called it may be called multiples times again so take care about how content Component s are dynamically created.

Specified by:
getTabContentAt in interface TabModel
Parameters:
index - - the index of the tab
Returns:
- the component which makes up the tabs content at index or null if there isnt a component at the index
See Also:
TabModel.getTabContentAt(int)

releaseTabAt

public void releaseTabAt(int index)
Does nothing as all tabs are kept in memory once added to this TabModel implementation.

Specified by:
releaseTabAt in interface TabModel
Parameters:
index - - the index of the tab to be released
See Also:
TabModel.releaseTabAt(int)

insertTab

public void insertTab(int index,
                      Component tabComponent,
                      Component tabContent)
Called to insert a new tab at the specified index. It will grow the collection of tabs to fit the new tab.

Parameters:
index - - the index to insert at, growing the collection as required
tabComponent - - the component to use as the tab for the given index
tabContent - - the content to use for the given index
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

insertTab

public void insertTab(int index,
                      java.lang.String tabTitle,
                      ImageReference icon,
                      Component tabContent)
Called to insert a new tab at the specified index. It will grow the collection of tabs to fit the new tab.

This will use the default colors and fonts defined by this TabModel

Parameters:
index - - the index to insert at, growing the collection as required
tabTitle - - the title of the tab
icon - - the icon to use on the tab
tabContent - - the content to use for the given index
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

addTab

public void addTab(Component tabComponent,
                   Component tabContent)
Adds a new tab to the end of the collection of tabs.

This will use the default colors and fonts defined by this TabModel if no color and font properties are set on the LabelEx at the time it was passed to the model.

Parameters:
tabComponent - - the component to use as the tab for the given index
tabContent - - the component to use as the tab content.

addTab

public void addTab(java.lang.String tabTitle,
                   Component tabContent)
Adds a new tab with the specified title. This will use the default colors and fonts defined by this TabModel

Parameters:
tabTitle - - the title of the new tab
tabContent - - the component to use as the tab content.

addTab

public void addTab(ImageReference icon,
                   Component tabContent)
Adds a new tab with the specified icon. This will use the default colors and fonts defined by this TabModel

Parameters:
icon - - the icon of rhe new tab
tabContent - - the component to use as the tab content.

addTab

public void addTab(java.lang.String tabTitle,
                   ImageReference icon,
                   Component tabContent)
Adds a new tab with the specified title and icon. This will use the default colors and fonts defined by this TabModel

Parameters:
tabTitle - - the title of the new tab
icon - - the icon of rhe new tab
tabContent - - the component to use as the tab content.

removeTabAt

public void removeTabAt(int index)
Removes the tab details at the specified index

Parameters:
index - - the index of the tab details
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

indexOfTab

public int indexOfTab(Component tabComponent)
Description copied from interface: TabModel
This is called to return the index of the component that makes up a tab.

Specified by:
indexOfTab in interface TabModel
Parameters:
tabComponent - - the component to return and index for
Returns:
the index of the component or -1 if it cant be found
See Also:
TabModel.indexOfTab(nextapp.echo2.app.Component)

getBackground

public Color getBackground()
Returns:
the background color to be used on non selected tabs

setBackground

public void setBackground(Color background)
Sets the background color to be used on non selected tabs


getFont

public Font getFont()
Returns:
the font to be used on non selected tabs

setFont

public void setFont(Font font)
Sets the font to be used on non selected tabs


getForeground

public Color getForeground()
Returns:
the foreground color to be used on non selected tabs

setForeground

public void setForeground(Color foreground)
Sets the foreground color to be used on non selected tabs


getSelectedBackground

public Color getSelectedBackground()
Returns:
the background color to be used on selected tabs

setSelectedBackground

public void setSelectedBackground(Color selectedBackground)
Sets the background color to be used on selected tabs


getSelectedFont

public Font getSelectedFont()
Returns:
the font to be used on selected tabs

setSelectedFont

public void setSelectedFont(Font selectedFont)
Sets the font to be used on selected tabs


getSelectedForeground

public Color getSelectedForeground()
Returns:
the foreground color to be used on selected tabs

setSelectedForeground

public void setSelectedForeground(Color selectedForeground)
Sets the foreground color to be used on selected tabs


getRolloverBackground

public Color getRolloverBackground()
Returns:
the background color to use on tab rollover

setRolloverBackground

public void setRolloverBackground(Color rolloverBackground)
Sets the background color to use on tab rollover


getRolloverFont

public Font getRolloverFont()
Returns:
the font to use on tab rollover

setRolloverFont

public void setRolloverFont(Font rolloverFont)
Sets the font to use on tab rollover


getRolloverForeground

public Color getRolloverForeground()
Returns:
the foreground color to use on tab rollover

setRolloverForeground

public void setRolloverForeground(Color rolloverForeground)
Set the foreground color to use on tab rollover


getSelectedRolloverBackground

public Color getSelectedRolloverBackground()
Returns:
the background color to use on rollover of selected tabs

setSelectedRolloverBackground

public void setSelectedRolloverBackground(Color selectedRolloverBackground)
Sets the background color to use on rollover of selected tabs


getSelectedRolloverFont

public Font getSelectedRolloverFont()
Returns:
the font to use on rollover of selected tabs

setSelectedRolloverFont

public void setSelectedRolloverFont(Font selectedRolloverFont)
Sets the font to use on rollover of selected tabs


getSelectedRolloverForeground

public Color getSelectedRolloverForeground()
Returns:
the foreground color to use on rollover of selected tabs

setSelectedRolloverForeground

public void setSelectedRolloverForeground(Color selectedRolloverForeground)
Sets the foreground color to use on rollover of selected tabs


getBorder

public Border getBorder()

setBorder

public void setBorder(Border border)

getRolloverBorder

public Border getRolloverBorder()

setRolloverBorder

public void setRolloverBorder(Border rolloverBorder)

getSelectedBorder

public Border getSelectedBorder()

setSelectedBorder

public void setSelectedBorder(Border selectedBorder)

getSelectedRolloverBorder

public Border getSelectedRolloverBorder()

setSelectedRolloverBorder

public void setSelectedRolloverBorder(Border selectedRolloverBorder)