|
MIDP3.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.microedition.lcdui.Displayable
javax.microedition.lcdui.Screen
javax.microedition.lcdui.TabbedPane
public class TabbedPane
TabbedPane is a Screen
subclass that presents a series of
Screens
to the users and allows them to navigate between screens
by selecting the corresponding tab.
Each tab has a Screen object that is its contents. Only
Form
and List
objects can be added as the contents
for a tab. Another TabbedPane cannot be used as the contents for a tab. A
Screen MUST only be placed on one tab at a time.
Each tab must include an icon Image
object or text to indicate
its content. Therefore, the TabbedPane class has two modes to represent the
contents of the tabs.
1) String mode In String mode, Strings are used to represent each tab's contents. The tab's name is the title of the tab content, which can be null. In this mode, TabbedPane's title area always displays TabbedPane's title to avoid redundancy.
2) Image mode
In Image mode, icons represent each tab's contents. The Image
may be mutable or immutable; if the Image
is mutable, the
effect is as if a snapshot of the Image is taken at the time the TabbedPane
is constructed or the tab is added to the TabbedPane. Subsequent drawing
operations performed on the Image
will not automatically
appear in the tab. Explicitly calling #setTabIcon with the same Image will
cause the icon to be refreshed with the Image's current contents.
Implementations may truncate or scale the icon image if it is larger than the
size supported by device. Applications can query the implementation's tab
icon size by calling Display.getBestImageWidth(int)
and
Display.getBestImageHeight(int)
methods using the Display.TAB
image type. The style and appearance of tabs are platform-dependent.
The number of tabs is not limited and may exceed the number that can be shown
on the screen at one time. In that case, implementations must indicate to
users that more tabs are available and provide a mechanism for accessing
them. An application can be notified of tab navigation events on a given
TabbedPane using the TabListener
interface.
In Image mode, the title shown for the TabbedPane depends on the suppressTitle
parameter. In String mode, TabbedPane's title is always shown to avoid redundancy.
Similarly, the TabbedPane's Ticker (if present) takes precedence over the Ticker belonging to the selected tab's contents.
Commands and Menus may be added to the TabbedPane and to the contents of its tabs. The Commands and Menus shown to the user include those belonging to the TabbedPane and those belonging to the selected tab's contents. A Command or Menu is shown only once even if it belongs to both objects. If such a Command is invoked, both objects' CommandListeners are notified; the listener for the tab's content is notified first, followed by that of the TabbedPane.
A tab is removed from the tabbed pane using removeTab(index)
.
If a tab at index n is removed, then the implementation must select the tab at
index n-1. If tab at index n-1 does not exist, then tab at index n+1 must be
selected. Therefore, getSelectedIndex()
after a
removeTab()
will return the next selected tab. If the
removeTab(index)
removes the last tab in the tabbedpane, then no tabs
are selected and the getSelectedIndex()
will return -1.
Calling setCurrent on the TabbedPane content MUST set the focus on the content. Calling setCurrent on the TabbedPane MUST set the focus on the first tab element, not the content. Calling setFocus MUST set the focus on the tab element indicated by the given index parameter. By default the focus MUST be on the first tab element.
The mechanism used by the user to navigate between tabs is implementation dependent. However, it must allow for the user to navigate within the contents of each tab and between tabs.
Initial State | Down Key press | Up key press | Left/Right key press |
Focus on tab (tab icon) | Focus is set into the tab content (screen object) | None or platform specific implementation. | Change tab focus to next/prior tab. The set of commands shown to the user changes to those belonging to the TabbedPane and those belonging to the newly selected tab's contents. A TabListener.tabChangeEvent is generated. |
Focus into the tab content (Screen object) | Default traversal already implemented on both Form and List classes. | Focus is set on tab (tab icon). This behavior supposes that the topmost focusable item is selected on tabbed pane content. If TabbedPane content has items that cannot get the focus, the traversal with hardware keys SHOULD be implemented so that if up key is pressed then the focus SHOULD move to the tab even if there are unfocusable items in-between. | Default traversal already implemented on either Form and List classes or specific device implementation. If there is no horizontal traversal in the tab content, the left and right keys SHOULD be reserved for traversing between tabs, and up and down keys for traversing inside the tab content. |
Constructor Summary | |
---|---|
TabbedPane(java.lang.String title,
boolean stringTab,
boolean suppressTitle)
Creates a new, empty TabbedPane, specifying its title. |
Method Summary | |
---|---|
void |
addTab(Screen tab,
Image icon)
Adds a tab element to the TabbedPane as the last element. |
void |
addTabListener(TabListener tabListener)
Sets a listener for focus change to this TabbedPane, replacing any previous TabListener. |
int |
getCount()
Gets the number of tab elements in the TabbedPane. |
int |
getHeight()
Returns the height in pixels of the area available for Displayables added to the TabbedPane . |
Screen |
getScreen(int index)
Gets the content for the tab references by the given index. |
int |
getSelectedIndex()
Returns the index number of a tab element (current tab) in the TabbedPane. |
Image |
getTabIcon(int index)
Gets the Image for the tab referenced by the given index. |
int |
getWidth()
Returns the width in pixels of the area available for Displayables added to the TabbedPane . |
void |
insertTab(int index,
Screen tab,
Image icon)
Inserts a tab element into the TabbedPane just prior to the element specified. |
void |
removeTab(int index)
Removes a tab element from TabbedPane. |
void |
setFocus(int index)
Sets the focus on a tab element. |
void |
setTabIcon(int index,
Image icon)
Sets the Image part of the tab element referenced by index, replacing the previous image of the tab. |
Methods inherited from class javax.microedition.lcdui.Displayable |
---|
addCommand, getCommand, getCommandLayoutPolicy, getCommands, getCurrentDisplay, getMenu, getTicker, getTitle, invalidateCommandLayout, isShown, removeCommand, removeCommandOrMenu, setCommand, setCommandLayoutPolicy, setCommandListener, setMenu, setTicker, setTitle, sizeChanged |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TabbedPane(java.lang.String title, boolean stringTab, boolean suppressTitle)
title
- the screen's title (see Displayable
).stringTab
- a boolean value representing the mode of the TabbedPanesuppressTitle
- a boolean value representing the state of the screen's title.Method Detail |
---|
public void addTab(Screen tab, Image icon)
tab
- screen object (tab element) to be added.icon
- image part of the tab element.
java.lang.NullPointerException
- if the icon is null and the TabbedPane is in "Image mode",
or if the tab is null in any mode
java.lang.IllegalArgumentException
- if the screen is not an instance of Form
,
or List
java.lang.IllegalStateException
- if the tab
has already been placed on this or another TabbedPane
java.lang.IllegalStateException
- if the tab
is current on another Display
public void addTabListener(TabListener tabListener)
tabListener
- The new listener or null.public void insertTab(int index, Screen tab, Image icon)
index
- the index of the tab where insertion is to occur, starting from zero.tab
- the tab object (Screen) to be inserted.icon
- the image part of the tab element.
java.lang.IndexOutOfBoundsException
- if index is not within the range [0..getCount()], inclusive.
java.lang.NullPointerException
- if either tab or icon is null while the TabbedPane is in
"Image mode"
java.lang.IllegalArgumentException
- if the screen is not an instance of Form
,
or List
java.lang.IllegalStateException
- if the tab
has already been placed on this or another TabbedPane
java.lang.IllegalStateException
- if the tab
is current on another Display
public void setFocus(int index)
index
- the index of the tab element to receive the focus.
java.lang.IndexOutOfBoundsException
- if index is not within the range [0..getCount()-1], inclusive.public void setTabIcon(int index, Image icon)
index
- the index of the tab element to be set.icon
- the new image of the tab element.
java.lang.IndexOutOfBoundsException
- if index is not within the range [0..getCount()-1], inclusive.
java.lang.NullPointerException
- if icon is null while the TabbedPane is in
"Image mode"public void removeTab(int index)
index
- the index number of the tab to be removed.
java.lang.IndexOutOfBoundsException
- if index is not within the range [0..getCount()-1], inclusive.public int getCount()
public int getSelectedIndex()
public Screen getScreen(int index)
index
- the index number of the tab to be returned, starting from zero.
java.lang.IndexOutOfBoundsException
- if index is not within the range [0..getCount()-1], inclusive.public Image getTabIcon(int index)
index
- the index number of the tab to be queried.
java.lang.IndexOutOfBoundsException
- if index is not within the range [0..getCount()-1], inclusive.public int getWidth()
Displayables
added to the TabbedPane
.
This area excludes the tabs themselves and any borders that are
drawn around the added Displayables
. The width
returned is the maximum width that getWidth
and getWidth
can return if the
Form
or List
is in focus within the
TabbedPane
.
getWidth
in class Displayable
Form
or a List
public int getHeight()
Displayables
added to the TabbedPane
.
This area excludes the tabs themselves and any borders that are
drawn around the added Displayables
. The height
returned is the maximum height that
getHeight
and
getHeight
can return if the
Form
or List
is in focus within the
TabbedPane
.
getHeight
in class Displayable
Form
or a List
|
MIDP3.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |