Packages
 In this topic

*Constructors

*Methods

 

Packages   PreviousThis PackageNext
Package com.ms.ui   Previous This
Package
Next

 


Class UITabViewer

public class UITabViewer extends UIPanel
{
  // Constructors
  public UITabViewer();

  // Methods
  public IUIComponent add(String name, IUIComponent comp);
  public synchronized void addItemListener(IUIItemListener l);
  public void addNotify();
  public IUIComponent addTab(IUIComponent tab,
        IUIComponent content);
  public Insets getInsets();
  public int getSelectedIndex();
  public IUIComponent getSelectedItem();
  public boolean handleEvent(Event e);
  public void paint(FxGraphics g);
  public boolean postEvent(Event e);
  protected void processEvent(UIEvent e);
  protected void processItemEvent(UIItemEvent e);
  public synchronized void removeItemListener(IUIItemListener l);
  public void removeTab(int index);
  public void removeTab(IUIComponent comp);
  public void requestFocus();
  public void setSelectedIndex(int index);
  public void setSelectedItem(IUIComponent comp);
}

This class implements a tab viewer control. UITabViewer works in conjunction with UITabList to display a list of tabs and their associated pages. UITabViewer uses UITabLayout for its layout manager.

A UITabViewer object is empty when it is first created. The add and addTab methods enable 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 and a page that both display text.
tv.add("Tab 1", new UIText("Page 1"));

// Add a tab that displays the graphical image stored 
// in the variable myImage, with a page that displays 
// a check box button.
tv.addTab(new UIGraphic(myImage), 
          new UICheckButton("Button on Page 2"));

// Add a UITab object with a page that displays the 
// UIList object myList.
UITab t = new UITab("Tab 3");
tv.addTab(t, myList);

// Now add the tab viewer to the container.
add(tv);

Note When you call add with a String, the tab is automatically hot-tracked. To override this default, call addTab with a UIText object, as shown in the following example.

// Add a tab that displays a String. 
// By default, the tab is hot-tracked.
tv.add("hot", myPage);

// Add a tab that is not hot-tracked, using UIText. 
tv.addTab(new UIText("not hot"), myPage);

// To create a hot-tracked tab using UIText,
// specify the UIStatic.HOTTRACK style. 
tv.addTab(new UIText("hot UIText", UIStatic.HOTTRACK), myPage);

For more information about hot-tracking, see the UIText overview.

Note The hot-track color is the same color as the button text color. As a result, hot-tracking does not appear to be functional.

Comments: UITabViewer will put scroll arrows on the control if the tabs do not fit the control.

UIComponent
  |
  +--UIContainer
    |
    +--UIStateContainer
      |
      +--UIPanel
        |
        +--UITabViewer

Constructors

UITabViewer

public UITabViewer();

Creates an empty tab viewer control.

Remarks:

Call add or addTab to insert a tab and its associated page into the control.

Methods

add

public IUIComponent add(String name, IUIComponent 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, if successful; otherwise, returns null.

ParameterDescription
name The text to be displayed on the tab.
comp The component to be displayed on the page that is associated with the tab.

Remarks:

If the name parameter identifies a tab that already exists in the tab viewer, this tab's page is updated with comp. Otherwise, a new tab and page are added. A tab's page is displayed only when the tab is selected.

By default, the tab is hot-tracked. To add a tab that is not hot-tracked, call the addTab method and pass a UIText object. For more information about hot-tracking, see the UITabViewer overview.

addItemListener

public synchronized void addItemListener(IUIItemListener l);

Adds the specified item listener. The listener receives all item events generated for the control. (Item events are generated when the state of an item changes.)

Return Value:

No return value.

ParameterDescription
l The item listener to be added.

See Also: removeItemListener

addNotify

public void addNotify();

Called to perform initialization when the graphics context is first available.

Return Value:

No return value.

Remarks:

This method determines whether a tab is selected. If no tab is selected, addNotify sets the selection to the first tab in the tab viewer control.

addTab

public IUIComponent addTab(IUIComponent tab, IUIComponent 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, if successful; otherwise, returns null.

ParameterDescription
tab The component to be displayed on the tab. If comp is a UITab object, this tab is added. Otherwise, a new UITab object that displays comp is added.
content The component to be displayed on the page that is associated with the tab.

Remarks:

If the name parameter identifies a tab that already exists in the tab viewer, this tab's page is updated with content. Otherwise, a new tab and page are added. A tab's page is displayed only when the tab is selected.

Typically, you'll pass a UIText, UIGraphic, or UIItem object for the component. For examples of how to add tabs, see the UITabViewer overview.

getInsets

public Insets getInsets();

Retrieves the tab viewer control's insets (in pixels), which identify the nonclient area of the control.

Return Value:

Returns an Insets object containing control's insets.

getSelectedIndex

public int getSelectedIndex();

Retrieves the zero-based index of the tab that is currently selected.

Return Value:

Returns the index of the selected tab, or -1 if no tab is selected.

See Also: getSelectedItem, setSelectedIndex

getSelectedItem

public IUIComponent getSelectedItem();

Retrieves the tab that is currently selected.

Return Value:

Returns the selected tab, or null if no tab is selected.

See Also: getSelectedItem, setSelectedIndex

handleEvent

public boolean handleEvent(Event e);

Determines whether a tab in the list has been selected, and if so, shows its associated page.

Return Value:

Returns true if the event was handled; otherwise, returns false.

ParameterDescription
e The event.

paint

public void paint(FxGraphics g);

Draws the tab viewer control.

Return Value:

No return value.

ParameterDescription
g The graphics context.

postEvent

public boolean postEvent(Event e);

Posts the specified event to the control.

Return Value:

Returns true if the event was handled; otherwise, returns false.

ParameterDescription
e The event.

processEvent

protected void processEvent(UIEvent e);

Processes the specified event.

Return Value:

No return value.

ParameterDescription
e The event.

Remarks:

This method is automatically invoked if a listener has has been registered through a call to addXXXListener. Depending on the type of event, processEvent calls one of the following methods.

Event type Method called
item event processItemEvent
container event processContainerEvent (inherited through UIStateContainer)
focus event processFocusEvent (inherited through UIStateContainer)
key event processKeyEvent (inherited through UIStateContainer)
mouse event processMouseEvent (inherited through UIStateContainer)
mouse motion event processMouseMotionEvent (inherited through UIStateContainer)

When overriding processEvent, call the super method processEvent to ensure the default event processing continues normally.

processItemEvent

protected void processItemEvent(UIItemEvent e);

Processes item events.

Return Value:

No return value.

ParameterDescription
e The item event.

Remarks:

This method is called by processEvent and dispatches the event to a registered item listener. When overriding this method, call the super method processItemEvent to ensure the default event processing continues normally.

See Also: addItemListener

removeItemListener

public synchronized void removeItemListener(IUIItemListener l);

Removes the specified item listener. The listener no longer receives the control's item events.

Return Value:

No return value.

ParameterDescription
l The item listener to be removed.

See Also: addItemListener

removeTab

public void removeTab(int index);

Removes the tab and page from the tab viewer.

Return Value:

No return value.

ParameterDescription
index The index of the tab and its associated page to remove.

removeTab

public void removeTab(IUIComponent comp);

Removes the tab and page from the tab viewer.

Return Value:

No return value.

ParameterDescription
comp Specifies either the tab or the page of the tab-page pair that is to be removed.

requestFocus

public void requestFocus();

Transfers the focus to the tab viewer control's content component.

Return Value:

No return value.

setSelectedIndex

public void setSelectedIndex(int index);

Selects the tab at the specified index.

Return Value:

No return value.

ParameterDescription
index The zero-based index of the tab to be selected.

Remarks:

When the specified tab is selected, its associated page is shown.

See Also: setSelectedItem

setSelectedItem

public void setSelectedItem(IUIComponent comp);

Selects the tab that is identified by the specified component.

Return Value:

No return value.

ParameterDescription
comp The component identifying the tab to be selected. If comp is a tab object, this tab is selected. If comp is the component displayed on a tab, the tab containing comp is selected.

Remarks:

When the specified tab is selected, its associated page is shown.

See Also: setSelectedIndex

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.