Package com.ms.ui |
![]() Previous |
![]() Contents |
![]() Index |
![]() Next |
public class UITabViewer extends UIPanel { // Constructors public UITabViewer(); // Methods public Component add(String name, Component comp); public Component addTab(Component tab, Component content); public void setSelectedIndex(int index); public void setSelectedItem(Component comp); public Insets insets(); public void paint(Graphics g); public boolean handleEvent(Event e); }
A class that implements a tab viewer control; uses UITab and UITabList to display a list of tabs with their associated pages.
A UITabViewer object is initially empty when first created. The add and addTab methods allow you to insert tabs and their pages. The following example shows how to use these methods.
// Construct a UITabViewer object. UITabViewer tv = new UITabViewer(); // Add a tab that displays the text "Tab 1", and a page // that displays the text "Page 1". tv.add("Tab 1", new UIText("Page 1")); // Add a tab that displays the graphic image stored in the // variable myImage, and a page that displays a check box button. tv.addTab(new UIGraphic(myImage), new UICheckButton("My CheckButton")); // Create a UITab object and add it to the tab viewer // with a page that displays the text "Page 3". UITab t = new UITab("Tab 3"); tv.addTab(t, new UIText("Page 3")); // Now add the tab viewer to the container. add(tv);
public UITabViewer();Creates an empty tab viewer control.
Remarks:
Call add or addTab to insert tabs and their pages into the control.
public Component add(String name, Component comp);Adds a tab and its associated page to the tab viewer control. The tab displays the specified text and the page displays the specified component.
Return Value:
Returns the page component that was added.
Parameter Description name The text to be displayed on the tab. comp The component to be used for the page associated with the tab. Remarks:
If the name parameter identifies a tab that already exists in the tab viewer, then this tab's page is updated with comp. Otherwise, a new tab is added. Note that a tab's page will be loaded only when the tab is selected.
By default, the text on the tab is hot-tracked. To display text that is not hot-tracked, call the addTab method and pass a UIText object, as shown in the following example.
UITabViewer tv = new UITabViewer(); tv.addTab(new UIText("Text not hot-tracked"), new UIText("Page Content"));
public Component addTab(Component tab, Component content);Adds a tab and its associated page to the tab viewer control. The tab and page display the specified components.
Return Value:
Returns the page component that was added.
Parameter Description name The component to be displayed on the tab being added. If comp is already a tab object, then this tab is added. Otherwise, a new tab is created. comp The component to be used for the page associated with the tab. Remarks:
If the tab parameter identifies a tab that already exists in the tab viewer, then this tab's page is updated with content. Otherwise, a new tab is added. Note that a tab's page will be loaded only when the tab is selected.
Typically, you'll pass a UIText, UIGraphic, or UIText object for the component. Note that by default, the component is not hot-tracked. To add this support, include the UIStatic.HOTTRACK flag, as shown in the following example.
UITabViewer tv = new UITabViewer(); tv.addTab(new UIText("Hot-tracked text", UIStatic.HOTTRACK), new UIText("Page Content"));In addition to addTab, UITabViewer defines the add method, specifically for displaying text on a tab.
public boolean handleEvent(Event e);Determines if a tab in the list has been selected, and, if so, shows the associated page and validates the control.
Return Value:
Returns true if the event was handled; otherwise, returns false.
Parameter Description e The event.
public Insets insets();Determines the tab viewer control's insets (in pixels), which indicate the size of the control's border.
Return Value:
Returns an Insets object containing the tab viewer control's insets.
public void paint(Graphics g);Draws the tab viewer control.
Return Value:
No return value.
Parameter Description g The graphics context.
public void setSelectedIndex(int index);Selects the tab at the specified index.
Return Value:
No return value.
Parameter Description index The zero-based index of the tab to be selected. Remarks:
When the specified tab is selected, its associated page is shown.
public void setSelectedItem(Component comp);Selects the tab identified by the specified component.
Return Value:
No return value.
Parameter Description comp Identifies the tab to be selected. If comp is a tab object, then this tab is selected. If comp is the component displayed on a tab, then the tab containing comp is selected. Remarks:
When the specified tab is selected, its associated page is shown.
© 1997 Microsoft Corporation. All rights reserved. Legal Notices.