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 Name | Property Type | Description |
Style | int |
Folder tab position style flag. |
Border | Insets |
Border space around the content component.
|
PageCount | int(Readonly) |
Number of pages in the CardFile.
|
CurrentTab | String(Readonly) |
The current tab string.
|
TabForeground | Color(Indexed, Writeonly) |
Tab foreground color.
|
TabBackground | Color(Indexed, Writeonly) |
Tab background color.
|
TabFont | Font(Indexed, Writeonly) |
Tab text font.
|
3D | boolean |
3D or plain apparence.
|
Visible | boolean (Indexed) |
Visibility of individual tabbed pages.
|
Folder generates the following events:
Event Type | Event ID | Generated |
Description |
ActionEvent | ActionEvent.ACTION_PERFORMED |
Tabbed page selected |
ActionEvent.getActionCommand() contains the tab name. |
-
BOTTOM
- Display the tabs at bottom of the folder.
-
eventMgr
- EventMgr object handles added event processing and dispatching.
-
LEFT
- Display the tabs at left side of the folder.
-
RIGHT
- Display the tabs at right side of the folder.
-
TOP
- Display the tabs at top of the folder.
-
Folder()
- Create an empty Folder.
-
Folder(int)
- Create an empty Folder with specified the style of the folder.
-
add(Component, Object)
- Add a component to the folder.
-
addActionListener(ActionListener)
- Add an action listener.
-
doLayout()
- Layout the tabs and their associated components.
-
getBorder()
- Get the content component border.
-
getCurrentTab()
- Get the current tab name.
-
getIndex(String)
- Get the tab index of the specified tab name.
-
getMinimumSize()
- Return the minimum size of the Folder.
-
getName(int)
- Get the tab name string of the specified index.
-
getPageCount()
- Get the number of pages inside this folder.
-
getPreferredSize()
- Return the preferred size of the Folder.
-
getStyle()
- Get the folder style option.
-
getTabBackground(int)
-
Get the tab background color.
-
getTabBackground(String)
-
Get the tab background color.
-
getTabFont(int)
-
Get the tab font.
-
getTabFont(String)
-
Get the tab font.
-
getTabForeground(int)
-
Get the tab foreground color.
-
getTabForeground(String)
-
Get the tab background color.
-
is3D()
- Return the 3D mode flag.
-
paint(Graphics)
- Paint the folder.
-
processActionEvent(ActionEvent)
- Process and dispatch action event.
-
processEvent(AWTEvent)
- Process and dispatch event.
-
remove(int)
- Remove the specified folder page from the folder.
-
remove(String)
- Remove the named folder page from the folder.
-
removeActionListener(ActionListener)
- Remove an action listener.
-
rename(String, String)
- Rename a folder page tab to a new name.
-
reset()
- Show a blank page (no tab selected).
-
set3D(boolean)
- Set folder 3D mode to true or false.
-
setBorder(Insets)
- Set the border for the content component.
-
setStyle(int)
- Set the folder to a new style.
-
setTabBackground(int, Color)
-
Set the tab background color.
-
setTabBackground(String, Color)
-
Set the tab background color.
-
setTabFont(int, Font)
-
Set the tab font.
-
setTabFont(String, Font)
-
Set the tab font.
-
setTabForeground(int, Color)
-
Set the tab foreground color.
-
setTabForeground(String, Color)
-
Set the tab background color.
-
setVisible(int, boolean)
- Make the idx'th tab visible or invisible.
-
setVisible(String, boolean)
- Make the named tab visible or invisible.
-
toFront(int)
- Make the idx'th tab the currently displayed one (on the top).
-
toFront(String)
- Make the named tab the currently displayed one (on the top).
LEFT
public static final int LEFT
- Display the tabs at left side of the folder.
BOTTOM
public static final int BOTTOM
- Display the tabs at bottom of the folder.
RIGHT
public static final int RIGHT
- Display the tabs at right side of the folder.
TOP
public static final int TOP
- Display the tabs at top of the folder.
eventMgr
protected EventMgr eventMgr
- EventMgr object handles added event processing and dispatching.
Folder
public Folder()
- Create an empty Folder. The default style is tab at top.
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.
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.
getStyle
public int getStyle()
- Get the folder style option.
- Returns:
- folder style.
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.
getBorder
public Insets getBorder()
- Get the content component border.
- Returns:
- component border.
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.
is3D
public boolean is3D()
- Return the 3D mode flag.
- Returns:
- true if this folder is in 3D mode.
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
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.
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
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.
getPageCount
public int getPageCount()
- Get the number of pages inside this folder.
- Returns:
- number of pages.
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.
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.
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().
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.
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
toFront
public void toFront(String name)
- Make the named tab the currently displayed one (on the top).
- Parameters:
- name - tab string.
getCurrentTab
public String getCurrentTab()
- Get the current tab name. If no tab is displayed, a null is returned.
- Returns:
- current tab.
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.
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.
getTabForeground
public synchronized Color getTabForeground(int idx)
- Get the tab foreground color.
- Parameters:
- idx - tab index, starts from 0.
- Returns:
- tab foreground color.
getTabForeground
public synchronized Color getTabForeground(String name)
- Get the tab background color.
- Parameters:
- name - tab string.
- Returns:
- tab foreground color.
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.
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.
getTabBackground
public synchronized Color getTabBackground(int idx)
- Get the tab background color.
- Parameters:
- idx - tab index, starts from 0.
- Returns:
- tab background color.
getTabBackground
public synchronized Color getTabBackground(String name)
- Get the tab background color.
- Parameters:
- name - tab string.
- Returns:
- tab background color.
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.
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.
getTabFont
public synchronized Font getTabFont(int idx)
- Get the tab font.
- Parameters:
- idx - tab index, starts from 0.
- Returns:
- tab font.
getTabFont
public synchronized Font getTabFont(String name)
- Get the tab font.
- Parameters:
- name - tab name string.
- Returns:
- tab font.
reset
public synchronized void reset()
- Show a blank page (no tab selected).
getMinimumSize
public Dimension getMinimumSize()
- Return the minimum size of the Folder.
- Returns:
- minimum size of folder.
- Overrides:
- getMinimumSize in class Container
getPreferredSize
public Dimension getPreferredSize()
- Return the preferred size of the Folder.
- Returns:
- preferred size of folder.
- Overrides:
- getPreferredSize in class Container
doLayout
public synchronized void doLayout()
- Layout the tabs and their associated components.
- Overrides:
- doLayout in class Container
addActionListener
public void addActionListener(ActionListener listener)
- Add an action listener.
- Parameters:
- listener - action listener.
removeActionListener
public void removeActionListener(ActionListener listener)
- Remove an action listener.
- Parameters:
- listener - action listener.
processEvent
public void processEvent(AWTEvent e)
- Process and dispatch event.
- Parameters:
- e - event object.
- Overrides:
- processEvent in class Container
processActionEvent
public void processActionEvent(ActionEvent e)
- Process and dispatch action event.
- Parameters:
- e - action event.
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