All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class tea.set.Folder

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----tea.set.Folder

public class Folder
extends Panel
Folder class is a container that provides an interface similar to a file folder. Files can be added to the folder by calling add(String, Component) method. The String argument is the tab name for the file. The Component argument can be another container within which more component can be added, or a simply component which will be resized to fit the content area of the folder. The default size of a folder is the maximum preferred size of its components plus the space for the tabs.

There are four styles of display:

LEFT
tab displayed at left of the folder
BOTTOM
tab displayed at bottom of the folder
RIGHT
tab displayed at right of the folder
TOP
tab displayed at top of the folder
The style of the folder can be set at construction time, or anytime after a Folder has been constructed. The minimumSize and preferredSize of the Folder is only an approximate. For optimum effect, set a reasonable size explicitly.

If tabs don't fit into one row, they are arranged in multiple rows. When a tab is selected, if it's not at the first row, it will be brought to the first row along with other tabs on the same row. An action event is generated when a folder is selected and brought to front. The target of the event is the Folder itself, and the arg is the string containing the tab of the folder file.

Tab foreground and background colors can be changed. The colors are only used when displaying tab area. The content area of the folder is not affected. The font of the tab string can also be changed so tabs can be displayed in different fonts.

The content component takes up all available space inside the content page by default. It's often better to leave some space between the component and the folder border. This can be accomplished by calling Folder.setBorder() method to set the component border.

A tabbed page can be removed dynamically. When a tabbed page is removed, the tabs are re-arranged. A tabbed folder page can also be renamed. Renaming a tabbed page only changes the tab string, the folder page itself is not affected.

When a folder page is selected, an action event is triggered. The Event.target points to the current folder, and Event.arg points to a String containing the tab string associated with the selected folder page.

Folder supports the following properties:
Property NameProperty TypeDescription
Styleint Folder tab position style flag.
BorderInsets Border space around the content component.
PageCountint(Readonly) Number of pages in the CardFile.
CurrentTabString(Readonly) The current tab string.
TabForegroundColor(Indexed, Writeonly) Tab foreground color.
TabBackgroundColor(Indexed, Writeonly) Tab background color.
TabFontFont(Indexed, Writeonly) Tab text font.
3Dboolean 3D or plain apparence.
Visibleboolean (Indexed) Visibility of individual tabbed pages.

Folder generates the following events:
Event TypeEvent IDGenerated Description
ActionEventActionEvent.ACTION_PERFORMED Tabbed page selected ActionEvent.getActionCommand() contains the tab name.


Variable Index

 o BOTTOM
Display the tabs at bottom of the folder.
 o eventMgr
EventMgr object handles added event processing and dispatching.
 o LEFT
Display the tabs at left side of the folder.
 o RIGHT
Display the tabs at right side of the folder.
 o TOP
Display the tabs at top of the folder.

Constructor Index

 o Folder()
Create an empty Folder.
 o Folder(int)
Create an empty Folder with specified the style of the folder.

Method Index

 o add(Component, Object)
Add a component to the folder.
 o addActionListener(ActionListener)
Add an action listener.
 o doLayout()
Layout the tabs and their associated components.
 o getBorder()
Get the content component border.
 o getCurrentTab()
Get the current tab name.
 o getIndex(String)
Get the tab index of the specified tab name.
 o getMinimumSize()
Return the minimum size of the Folder.
 o getName(int)
Get the tab name string of the specified index.
 o getPageCount()
Get the number of pages inside this folder.
 o getPreferredSize()
Return the preferred size of the Folder.
 o getStyle()
Get the folder style option.
 o getTabBackground(int)
Get the tab background color.
 o getTabBackground(String)
Get the tab background color.
 o getTabFont(int)
Get the tab font.
 o getTabFont(String)
Get the tab font.
 o getTabForeground(int)
Get the tab foreground color.
 o getTabForeground(String)
Get the tab background color.
 o is3D()
Return the 3D mode flag.
 o paint(Graphics)
Paint the folder.
 o processActionEvent(ActionEvent)
Process and dispatch action event.
 o processEvent(AWTEvent)
Process and dispatch event.
 o remove(int)
Remove the specified folder page from the folder.
 o remove(String)
Remove the named folder page from the folder.
 o removeActionListener(ActionListener)
Remove an action listener.
 o rename(String, String)
Rename a folder page tab to a new name.
 o reset()
Show a blank page (no tab selected).
 o set3D(boolean)
Set folder 3D mode to true or false.
 o setBorder(Insets)
Set the border for the content component.
 o setStyle(int)
Set the folder to a new style.
 o setTabBackground(int, Color)
Set the tab background color.
 o setTabBackground(String, Color)
Set the tab background color.
 o setTabFont(int, Font)
Set the tab font.
 o setTabFont(String, Font)
Set the tab font.
 o setTabForeground(int, Color)
Set the tab foreground color.
 o setTabForeground(String, Color)
Set the tab background color.
 o setVisible(int, boolean)
Make the idx'th tab visible or invisible.
 o setVisible(String, boolean)
Make the named tab visible or invisible.
 o toFront(int)
Make the idx'th tab the currently displayed one (on the top).
 o toFront(String)
Make the named tab the currently displayed one (on the top).

Variables

 o LEFT
 public static final int LEFT
Display the tabs at left side of the folder.

 o BOTTOM
 public static final int BOTTOM
Display the tabs at bottom of the folder.

 o RIGHT
 public static final int RIGHT
Display the tabs at right side of the folder.

 o TOP
 public static final int TOP
Display the tabs at top of the folder.

 o eventMgr
 protected EventMgr eventMgr
EventMgr object handles added event processing and dispatching.

Constructors

 o Folder
 public Folder()
Create an empty Folder. The default style is tab at top.

 o Folder
 public Folder(int style)
Create an empty Folder with specified the style of the folder.

Parameters:
style - folder style, one of the style flag values.

Methods

 o setStyle
 public synchronized void setStyle(int style)
Set the folder to a new style. The folder will be redrawn after the style is changed.

Parameters:
style - folder style, one of the style flag values.
 o getStyle
 public int getStyle()
Get the folder style option.

Returns:
folder style.
 o setBorder
 public synchronized void setBorder(Insets border)
Set the border for the content component. The border is the space between the component and the folder edges.

Parameters:
border - space between component and the border of folder.
 o getBorder
 public Insets getBorder()
Get the content component border.

Returns:
component border.
 o set3D
 public synchronized void set3D(boolean mode)
Set folder 3D mode to true or false. The default mode is 3D.

Parameters:
mode - display in 3D if true.
 o is3D
 public boolean is3D()
Return the 3D mode flag.

Returns:
true if this folder is in 3D mode.
 o add
 public void add(Component comp,
                 Object name)
Add a component to the folder. String is used as the tab name. Component is used as the content.

Parameters:
name - tab string.
comp - folder page content component.
Overrides:
add in class Container
 o remove
 public void remove(String name)
Remove the named folder page from the folder. The tabs are re-arranged after a page is removed.

Parameters:
name - tab string.
 o remove
 public synchronized void remove(int idx)
Remove the specified folder page from the folder. The tabs are re-arranged after a page is removed.

Parameters:
idx - tabbed page index.
Overrides:
remove in class Container
 o rename
 public synchronized void rename(String oname,
                                 String name)
Rename a folder page tab to a new name.

Parameters:
oname - the original tab string.
name - the new tab string.
 o getPageCount
 public int getPageCount()
Get the number of pages inside this folder.

Returns:
number of pages.
 o getIndex
 public int getIndex(String name)
Get the tab index of the specified tab name. If the tab string is not found, -1 is returned.

Parameters:
name - tab string to search for.
Returns:
tab index of the specified tab string, -1 if not found.
 o getName
 public String getName(int idx)
Get the tab name string of the specified index. The index must be between 0 and the number of tabs minus one. Otherwise a null value is returned.

Parameters:
idx - tab index.
Returns:
tab name of the specified tab, or null if index is out of range.
 o setVisible
 public synchronized void setVisible(int idx,
                                     boolean f)
Make the idx'th tab visible or invisible. Note this function just hide or unhide the tab, but do not make it current. @See toFront().

Parameters:
idx - folder index, in the order of add().
 o setVisible
 public void setVisible(String name,
                        boolean f)
Make the named tab visible or invisible. Note this function just hide or unhide the tab, but do not make it current. @See toFront().

Parameters:
name - tab string.
 o toFront
 public synchronized void toFront(int idx)
Make the idx'th tab the currently displayed one (on the top).

Parameters:
idx - folder index, in the order of #add
 o toFront
 public void toFront(String name)
Make the named tab the currently displayed one (on the top).

Parameters:
name - tab string.
 o getCurrentTab
 public String getCurrentTab()
Get the current tab name. If no tab is displayed, a null is returned.

Returns:
current tab.
 o setTabForeground
 public synchronized void setTabForeground(int idx,
                                           Color fg)
Set the tab foreground color. This does not affect the page color. If this method is not called, each tab inherites color from the Folder widget.

Parameters:
idx - tab index, starts from 0.
fg - foreground color.
 o setTabForeground
 public synchronized void setTabForeground(String name,
                                           Color fg)
Set the tab background color. This does not affect the page color. If this method is not called, each tab inherites color from the Folder widget.

Parameters:
name - tab string.
fg - foreground color.
 o getTabForeground
 public synchronized Color getTabForeground(int idx)
Get the tab foreground color.

Parameters:
idx - tab index, starts from 0.
Returns:
tab foreground color.
 o getTabForeground
 public synchronized Color getTabForeground(String name)
Get the tab background color.

Parameters:
name - tab string.
Returns:
tab foreground color.
 o setTabBackground
 public synchronized void setTabBackground(int idx,
                                           Color bg)
Set the tab background color. This does not affect the page color. If this method is not called, each tab inherites color from the Folder widget.

Parameters:
idx - tab index, starts from 0.
fg - background color.
 o setTabBackground
 public synchronized void setTabBackground(String name,
                                           Color bg)
Set the tab background color. This does not affect the page color. If this method is not called, each tab inherites color from the Folder widget.

Parameters:
name - tab string.
fg - background color.
 o getTabBackground
 public synchronized Color getTabBackground(int idx)
Get the tab background color.

Parameters:
idx - tab index, starts from 0.
Returns:
tab background color.
 o getTabBackground
 public synchronized Color getTabBackground(String name)
Get the tab background color.

Parameters:
name - tab string.
Returns:
tab background color.
 o setTabFont
 public synchronized void setTabFont(int idx,
                                     Font fn)
Set the tab font. This does not affect the page content font. If this method is not called, each tab inherites font from the Folder widget.

Parameters:
idx - tab index, starts from 0.
fn - font.
 o setTabFont
 public synchronized void setTabFont(String name,
                                     Font fn)
Set the tab font. This does not affect the page content font. If this method is not called, each tab inherites font from the Folder widget.

Parameters:
name - tab name string.
fn - font.
 o getTabFont
 public synchronized Font getTabFont(int idx)
Get the tab font.

Parameters:
idx - tab index, starts from 0.
Returns:
tab font.
 o getTabFont
 public synchronized Font getTabFont(String name)
Get the tab font.

Parameters:
name - tab name string.
Returns:
tab font.
 o reset
 public synchronized void reset()
Show a blank page (no tab selected).

 o getMinimumSize
 public Dimension getMinimumSize()
Return the minimum size of the Folder.

Returns:
minimum size of folder.
Overrides:
getMinimumSize in class Container
 o getPreferredSize
 public Dimension getPreferredSize()
Return the preferred size of the Folder.

Returns:
preferred size of folder.
Overrides:
getPreferredSize in class Container
 o doLayout
 public synchronized void doLayout()
Layout the tabs and their associated components.

Overrides:
doLayout in class Container
 o addActionListener
 public void addActionListener(ActionListener listener)
Add an action listener.

Parameters:
listener - action listener.
 o removeActionListener
 public void removeActionListener(ActionListener listener)
Remove an action listener.

Parameters:
listener - action listener.
 o processEvent
 public void processEvent(AWTEvent e)
Process and dispatch event.

Parameters:
e - event object.
Overrides:
processEvent in class Container
 o processActionEvent
 public void processActionEvent(ActionEvent e)
Process and dispatch action event.

Parameters:
e - action event.
 o paint
 public void paint(Graphics g)
Paint the folder.

Parameters:
g - Graphics content of this component.
Overrides:
paint in class Container

All Packages  Class Hierarchy  This Package  Previous  Next  Index