Packages
 In this topic

*Constructors

*Methods

*Fields

 

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

 


Class UISlider

public class UISlider extends UIScroll
{
  // Fields
  public static final int DEFAULTSPACING;
  public static final int POINTDOWN;
  public static final int POINTLEFT;
  public static final int POINTRIGHT;
  public static final int POINTSABOVE;
  public static final int POINTSBELOW;
  public static final int POINTUP;
  public static final int RANGESELECT;
  public static final int TICKS_ABOVE;
  public static final int TICKS_BELOW;
  public static final int TICKSABOVE;
  public static final int TICKSBELOW;
  public static final int VERTICAL;

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

  // Methods
  public IUIComponent add(int index, IUIComponent comp);
  public void clearSelection();
  public Insets getInsets();
  public IUIComponent getLayoutComponent(int index);
  public Dimension getMinimumSize();
  public Dimension getPreferredSize();
  public int getSelectionEnd();
  public int getSelectionStart();
  public int getStyle();
  public int getTickSpacing();
  public void layout();
  public void removeAll();
  public void setSelection(int start, int end);
  public void setSelectionEnd(int end);
  public void setSelectionStart(int start);
  public int setSliderInfo(int min, int max, int page, int line,
        int pos, int spacing);
  public void setStyle(int style);
  public void setTickSpacing(int spacing);
}

This class implements a slider control. Slider controls are often used as a selector for a continuous range of values, such as volume control, contrast, or brightness.

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

Constructors

UISlider

public UISlider();

Creates a horizontal slider control with a range of 0-10 and default spacing of the tick marks.

UISlider

public UISlider(int style);

Creates either a horizontal or vertical slider control with a range of 0-10 and a default spacing of tick marks.

ParameterDescription
style The style of slider. This can be one or a combination of the following style flags:
VERTICAL 0 (for a horizontal slider)
POINTSABOVE POINTSBELOW
TICKSABOVE TICKSBELOW
RANGESELECT

UISlider

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

Creates a slider control with the given metrics and with the specified style.

ParameterDescription
style The style of slider. This can be one or a combination of the following style flags:
VERTICAL 0 (for a horizontal slider)
POINTSABOVE POINTSBELOW
TICKSABOVE TICKSBELOW
RANGESELECT
min The minimum value of the slider's range.
max The maximum value of the slider's range.
page The amount to scroll for a page up or page down. By default, this value is 0.
line The amount to scroll for a line up or line down. Typically, this value is 1.
pos The current position of the slider thumb. By default, this value is set to 0.
spacing The number of scroll positions between the tick marks (this can be DEFAULTSPACING).

Methods

add

public IUIComponent add(int index, IUIComponent comp);

Adds a component or replaces the specified existing component with the given component.

Return Value:

Returns the previous component if it was replaced by the added component.

ParameterDescription
index The layout index of component to replace. This can be one of the following layout indices:
THUMB
PAGE_UP
PAGE_DOWN
TICKS_ABOVE
TICKS_BELOW
comp The component to use in the slider.

Overrides:

add(int,IUIComponent) in UIScroll.

clearSelection

public void clearSelection();

Removes the selection highlight.

Return Value:

No return value.

getInsets

public Insets getInsets();

Retrieves the insets for the slider relative to its parent component, in pixels. This method is not called directly by the application. It is used in the layout method to lay out the slider control relative to its parent component.

Return Value:

Returns a set of Insets for the slider control.

getLayoutComponent

public IUIComponent getLayoutComponent(int index);

Retrieves the layout component at the given index.

Return Value:

Returns the component at that layout index; returns null if there is no component at the given index.

ParameterDescription
index The layout index of component. This can be one of the following layout indices:
THUMB
PAGE_UP
PAGE_DOWN
TICKS_ABOVE
TICKS_BELOW

Overrides:

getLayoutComponent(int) in UIScroll.

getMinimumSize

public Dimension getMinimumSize();

Retrieves the minimum layout size of the slider control, in pixels. This method is not called directly by the application. It is used in the layout method and other private methods to lay out the slider control.

Return Value:

Returns a Dimension that describes the minimum layout size.

Overrides:

getMinimumSize() in UIScroll.

getPreferredSize

public Dimension getPreferredSize();

Retrieves the preferred layout size of the slider control, in pixels. This method is not called directly by the application. It is used in the layout method and other private methods to lay out the slider control.

Return Value:

Returns a Dimension that describes the preferred layout size.

Overrides:

getPreferredSize() in UIScroll.

getSelectionEnd

public int getSelectionEnd();

Retrieves the end position of the selection range.

Return Value:

Returns the end position of the selection range.

See Also: getSelectionStart, setSelectionEnd

getSelectionStart

public int getSelectionStart();

Retrieves the start position of the selection range.

Return Value:

Returns start position of the selection range.

See Also: getSelectionEnd, setSelectionStart

getStyle

public int getStyle();

Retrieves the style for the slider.

Return Value:

Returns the current style settings for the slider. For a list of possible values, see setStyle.

Overrides:

getStyle() in UIScroll.

getTickSpacing

public int getTickSpacing();

Retrieves the spacing of the tick marks on the slider track.

Return Value:

Returns the spacing of the tick marks.

See Also: setTickSpacing

layout

public void layout();

This method is used to lay out the slider control.

Return Value:

No return value.

Overrides:

layout() in UIScroll.

removeAll

public void removeAll();

Removes all the current components from the slider control. This includes tick marks and the thumb object.

Return Value:

No return value.

setSelection

public void setSelection(int start, int end);

Sets the selection range for the slider.

Return Value:

No return value.

ParameterDescription
start The start position of the selection range.
end The end position of the selection range.

setSelectionEnd

public void setSelectionEnd(int end);

Set the end position of the selected range. This method ensures that the specified end position is within the range of the slider.

Return Value:

No return value.

ParameterDescription
end The end position of the selected range.

setSelectionStart

public void setSelectionStart(int start);

Sets the start position of the selection range. This method ensures that the specified start position is within the range of the slider.

Return Value:

No return value.

ParameterDescription
start The start position of the selected range.

setSliderInfo

public int setSliderInfo(int min, int max, int page, int line, int pos, int
        spacing);

Sets the slider control's metrics.

Return Value:

Returns the scroll position after setting its value.

ParameterDescription
min The minimum value of the slider's range.
max The maximum value of the slider's range.
page The amount to scroll for a page up or page down.
line The amount to scroll for a line up or line down.
pos The current position of the slider thumb.
spacing The spacing of the tick marks. Typically, this is set to DEFAULTSPACING for sliders with small ranges.

setStyle

public void setStyle(int style);

Sets the current style for the slider.

Return Value:

No return value.

ParameterDescription
style The style of slider. This can be one or a combination of the following style flags:
VERTICAL 0 (for a horizontal slider)
POINTSABOVE POINTSBELOW
TICKSABOVE TICKSBELOW
RANGESELECT

Overrides:

setStyle(int) in UIScroll.

setTickSpacing

public void setTickSpacing(int spacing);

Sets the spacing of the tick marks.

Return Value:

No return value.

ParameterDescription
spacing The spacing of the tick marks. This is typically set to DEFAULTSPACING.

Remarks:

The spacing is the number of scroll positions between tick marks. If the track has a range of 1 - 10, and the amount of scroll for a line up or line down is set to 1, 10 tick marks are on the track and the spacing is 1.

See Also: getTickSpacing

Fields

DEFAULTSPACING
A value indicating default spacing for tick marks.
POINTDOWN
The flag that specifies a horizontal slider points down, with tick marks below, on a horizontal slider track.
POINTLEFT
The flag that specifies a vertical slider points left, with tick marks on the left side of a vertical slider track.
POINTRIGHT
The flag that specifies a vertical slider points right with tick marks on the right side of a vertical slider track.
POINTSABOVE
The flag used to make an arrow point up or left, depending on the orientation of the slider track.
POINTSBELOW
The flag used to make an arrow point down or right, depending on the orientation of the slider track.
POINTUP
The flag that specifies a horizontal slider that points up, with tick marks above, on a horizontal slider track.
RANGESELECT
The flag used to allow a selection range in the slider. All selection methods are ignored if this style is not set.
TICKS_ABOVE
The layout index for the tick marks above the slider control.
TICKS_BELOW
The layout index for the tick marks below the slider control.
TICKSABOVE
The flag used to draw tick marks above or left, depending on the orientation of the slider track.
TICKSBELOW
The flag used to draw tick marks below or right, depending on the orientation of the slider track.
VERTICAL
A slider style used to make a vertical slider control track.

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