Packages
 In this topic

*Constructors

*Methods

*Fields

 

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

 


Class UIScrollBar

public class UIScrollBar extends UIScroll
{
  // Fields
  public static final int LINE_DOWN;
  public static final int LINE_UP;

  // Constructors
  public UIScrollBar();
  public UIScrollBar(int style);
  public UIScrollBar(int style, int min, int max, int page,
        int line, int pos);

  // Methods
  public IUIComponent add(int index, IUIComponent comp);
  public Insets getInsets();
  public IUIComponent getLayoutComponent(int index);
  public Dimension getMinimumSize();
  public Dimension getPreferredSize();
  public void layout();
  public void setStyle(int style);
}

This class implements a scroll bar control. UIScrollBar manages five components that enable you to move the scroll bar control's current position. Each component is identified by a layout index, described in the following table.

Layout Index Component
THUMB See the UIScroll overview.
PAGE_UP See the UIScroll overview.
PAGE_DOWN See the UIScroll overview.
LINE_UP The component that lies above or to the left of the track area. (By default, it is a UIRepeatButton object that displays the system-defined up or left arrow.) When the LINE_UP component is pressed with the mouse, the current position is moved in decrements of one line.
LINE_DOWN The component that lies below or to the right of the track area. (By default, it is a UIRepeatButton object that displays the system-defined down or right arrow.) When the LINE_DOWN component is pressed with the mouse, the current position is moved in increments of one line.

Typically, you'll attach a scroll bar to another object; for example, you may want to add scroll bars to a list control. In these cases, consider using UIScrollViewer, which combines a content component with UIScrollBar objects to create a single control. Unlike UIScrollBar, UIScrollViewer automatically repositions the content in response to changes in the scroll bars' positions.

For information about constructing UIScrollBar objects, see the UIScroll overview.

UIComponent
  |
  +--UIContainer
    |
    +--UIStateContainer
      |
      +--UIPanel
        |
        +--UIScroll
          |
          +--UIScrollBar

Constructors

UIScrollBar

public UIScrollBar();

Creates a horizontal scroll bar control. By default, the control has a range of 0 to 100.

UIScrollBar

public UIScrollBar(int style);

Creates a scroll bar control with the specified style. By default, the control has a range of 0 to 100.

ParameterDescription
style The style of the control. You can pass any bitwise combination of the following values:

Exceptions:

IllegalArgumentException if an undefined style was specified.

UIScrollBar

public UIScrollBar(int style, int min, int max, int page, int line,
        int pos);

Creates a scroll bar control with the specified style and scroll information.

ParameterDescription
style The style of the control. You can pass any bitwise combination of the following values:
min The minimum scroll position in the control's range.
max The maximum scroll position in the control's range.
page The number of scroll positions that are associated with a page. The size of the THUMB component is proportional to the total number of pages, unless the style is specified as UIScroll.NONPROPORTIONAL. The more pages, the smaller the THUMB component.
line The number of scroll positions that are associated with a line.
pos The current scroll position.

Remarks:

For more information about range, page, and line values, see the UIScroll overview.

Exceptions:

IllegalArgumentException if an undefined style was specified.

Methods

add

public IUIComponent add(int index, IUIComponent comp);

Adds the specified component at the given layout index. If a component already exists at this index, it is replaced with the specified component.

Return Value:

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

ParameterDescription
index The layout index of the component to be added. You can pass one of the following values:
comp The component to be added.

Overrides:

add(int,IUIComponent) in UIScroll.

Exceptions:

IllegalArgumentException if an undefined index was specified.

See Also: getLayoutComponent

getInsets

public Insets getInsets();

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

Return Value:

Returns an Insets object that contains the scroll bar's insets.

getLayoutComponent

public IUIComponent getLayoutComponent(int index);

Retrieves the component at the specified layout index.

Return Value:

Returns the specified component, if found. The value of the component may be null.

ParameterDescription
index The layout index of the component to be retrieved. You can pass one of the following values:

Overrides:

getLayoutComponent(int) in UIScroll.

Exceptions:

IllegalArgumentException if an undefined layout index was specified.

See Also: add

getMinimumSize

public Dimension getMinimumSize();

Retrieves the minimum size (in pixels) of the scroll bar control. The minimum size is based on the preferred size of each of the control's components.

Return Value:

Returns a Dimension object that contains the control's minimum size.

Overrides:

getMinimumSize() in UIScroll.

See Also: getPreferredSize

getPreferredSize

public Dimension getPreferredSize();

Retrieves the preferred size (in pixels) of the scroll track control. The preferred size is based on the preferred size of each of the control's components.

Return Value:

Returns a Dimension object containing the control's preferred size.

Overrides:

getPreferredSize() in UIScroll.

See Also: getMinimumSize

layout

public void layout();

Lays out the components of the scroll bar control.

Return Value:

No return value.

Remarks:

If the scroll bar control has the NOSHOW style, or if scrolling is unnecessary, the control will be hidden.

Note If the NOHIDE style is set, the control will be disabled if scrolling is unnecessary.

Overrides:

layout() in UIScroll.

setStyle

public void setStyle(int style);

Sets the current style for the scroll bar control.

Return Value:

No return value.

ParameterDescription
style The style of the control. You can pass one or a combination of the following values:

Overrides:

setStyle(int) in UIScroll.

Exceptions:

IllegalArgumentException if an undefined style was specified.

Fields

LINE_DOWN
The layout index for the component that lies below or to the right of the track area. By default, this component displays the system-defined down arrow or right arrow.
LINE_UP
The layout index for the component that lies above or to the left of the track area. By default, this component displays the system-defined up arrow or left arrow.

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