Packages
 In this topic

*Constructors

*Methods

 

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

 


Class UISingleContainer

public class UISingleContainer extends UIStateContainer
{
  // Constructors
  public UISingleContainer();
  public UISingleContainer(int edge);

  // Methods
  public IUIComponent add(IUIComponent comp, Object constraints,
        int index);
  public IUIComponent getChild(int index);
  public Rectangle getChildBounds(int index);
  public int getChildCount();
  public Point getChildLocation(int index);
  public Dimension getChildSize(int index);
  public IUIComponent getComponent(int index);
  public int getComponentCount();
  public IUIComponent getHeader();
  public void layout();
  public boolean mouseExit(Event e, int x, int y);
  public void relayout();
  public void remove(int index);
  public void setFocused(boolean on);
  public void setHeader(IUIComponent header);
  public void setID(int id);
  public void setName(String name);
}

This class implements a container for a single header component. Header components are used to represent the container itself; for example, the text displayed on a button is used as its header component. Unlike UIPanel, a UISingleContainer object cannot contain child components. UISingleContainer provides the getHeader and setHeader methods to retrieve and set the current header component.

The following diagram shows the classes that extend UISingleContainer.

UISingleContainer
|
+--UIButton
|
+--UIMenuLauncher
|
+--UIStatus
|
+--UITab
|
+--UIThumb
UIComponent
  |
  +--UIContainer
    |
    +--UIStateContainer
      |
      +--UISingleContainer

Constructors

UISingleContainer

public UISingleContainer();

Creates a UISingleContainer object with no edge.

UISingleContainer

public UISingleContainer(int edge);

Creates a UISingleContainer object with the specified edge.

ParameterDescription
edge The style of the container's edge. You can pass one of the following values:

Exceptions:

IllegalArgumentException if an undefined edge style was specified.

Methods

add

public IUIComponent add(IUIComponent comp, Object constraints, int index);

Adds the specified component to the container, according to the specified constraints and index.

Return Value:

Returns the component that was added (if successful); otherwise, returns null.

ParameterDescription
comp The component to be added.
constraints The layout constraints, which depend on the current layout manager. For more information, see the layout manager's addLayoutComponent method.
index The zero-based index at which to insert the component. Because the component can only be added as a header, possible index values include 0 or -1. (For more information about header components, see the UISingleContainer overview.)

Remarks:

Other versions of add are inherited from UIContainer.

Overrides:

add(IUIComponent,Object,int) in UIStateContainer.

Exceptions:

ArrayIndexOutOfBoundsException if an invalid index was specified.

See Also: remove

getChild

public IUIComponent getChild(int index);

Retrieves the child component at the specified index.

Return Value:

Returns null, because the container can only contain a header component and no child components.

ParameterDescription
index The zero-based index of the child component to be retrieved.

See Also: getComponent, getChildCount

getChildBounds

public Rectangle getChildBounds(int index);

Retrieves the bounding rectangle of the component at the specified index.

Return Value:

Returns a Rectangle object that identifies the component's bounding area (if the component is the container's header); otherwise, returns null.

ParameterDescription
index The zero-based index of the component. Because the container can only contain a header component, this method returns null if an index other than 0 is passed.

getChildCount

public int getChildCount();

Retrieves the number of child components in the container, excluding the header component.

Return Value:

Returns 0, because the container can only contain a header component.

See Also: getComponentCount, getChild

getChildLocation

public Point getChildLocation(int index);

Retrieves the location of the component at the specified index.

Return Value:

Returns a Point object containing the top-left corner of the component (if the component is the container's header); otherwise, returns null.

ParameterDescription
index The zero-based index of the component. Because the container can only contain a header component, this method returns null if an index other than 0 is passed.

getChildSize

public Dimension getChildSize(int index);

Retrieves the size of the component at the specified index.

Return Value:

Returns a Dimension object containing the component's dimensions (if the component is the container's header); otherwise, returns null.

ParameterDescription
index The zero-based index of the component. Because the container can only contain a header component, this method returns null if an index other than 0 is passed.

getComponent

public IUIComponent getComponent(int index);

Retrieves the component at the specified index.

Return Value:

Returns the component at the specified index, if found; otherwise, returns null.

ParameterDescription
index The zero-based index of the component to be retrieved. Because the container can only contain a header component, pass 0 to retrieve the header. This method returns null if any other index is passed.

See Also: getChild, getComponentCount

getComponentCount

public int getComponentCount();

Retrieves the number of components in the container.

Return Value:

Returns 1 if a header component is set; otherwise, returns 0.

See Also: getChildCount, getComponent

getHeader

public IUIComponent getHeader();

Retrieves the container's header component.

Return Value:

Returns the current header component (if the container has a header); otherwise, returns null. For more information about headers, see the UISingleContainer overview.

See Also: setHeader

layout

public void layout();

Lays out the container.

Return Value:

No return value.

Remarks:

This method is invoked when the container is validated.

See Also: relayout

mouseExit

public boolean mouseExit(Event e, int x, int y);

Responds to a mouse exit event.

Return Value:

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

ParameterDescription
e The event posted to the container.
x The x coordinate of the event.
y The y coordinate of the event.

Remarks:

This method prevents excess flickering when the mouse is moved in and out of the container. A mouse exit event is generated when the mouse exits the container's insets and enters the header component, and vice versa. In these cases, the mouseExit method simply returns false.

relayout

public void relayout();

Schedules the container to be laid out as soon as possible.

Return Value:

No return value.

See Also: layout

remove

public void remove(int index);

Removes the component at the specified index.

Return Value:

No return value.

ParameterDescription
index The zero-based index of the component to be removed. Because the container can only contain a header component, pass 0 to remove the header.

Overrides:

remove(int) in UIStateContainer.

See Also: add

setFocused

public void setFocused(boolean on);

Sets or clears the focus state of the button.

Return Value:

No return value.

ParameterDescription
on If true, the focus state is set; otherwise, it is cleared.

Remarks:

For more information about states, see the UIStateContainer overview.

Overrides:

setFocused(boolean) in UIStateContainer.

setHeader

public void setHeader(IUIComponent header);

Sets the header component for the container.

Return Value:

No return value.

ParameterDescription
header The component to be used as the container's header component. For more information about headers, see the UISingleContainer overview.

See Also: getHeader

setID

public void setID(int id);

Sets the container's identifier.

Return Value:

No return value.

ParameterDescription
id The value to be associated with the container.

See Also: setName

setName

public void setName(String name);

Sets the container's name.

Return Value:

No return value.

ParameterDescription
name The name to be associated with the container.

See Also: setID

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