Package com.ms.ui |
![]() Previous |
![]() Contents |
![]() Index |
![]() Next |
public class UIScroll extends UIPanel implements IUIScroll, IUIPosition { // Fields public static final int VERTICAL; public static final int NOHIDE; public static final int NOSHOW; public static final int THUMB; public static final int PAGE_UP; public static final int PAGE_DOWN; // Constructors public UIScroll(); public UIScroll(int style); public UIScroll(int style, int min, int max, int page, int line, int pos); // Methods public Component add(int index, Component comp); public void initGraphics(); public boolean isScrollable(); public Component getLayoutComponent(int index); public void layout(); public Dimension minimumSize(); public Dimension preferredSize(); public void reshape(int x, int y, int width, int height); public Color getBackground(); public Point getPosition(); public int getRoleCode(); public int getScrollLine(); public int getScrollMax(); public int getScrollMin(); public int getScrollPage(); public int getScrollPos(); public int getStyle(); public int getXPosition(); public int getYPosition(); public Point setPosition(Point pt); public Point setPosition(int x, int y); public int setScrollInfo(int min, int max, int page, int line, int pos); public int setScrollLine(int line); public int setScrollMax(int max); public int setScrollMin(int min); public int setScrollPage(int page); public int setScrollPos(int pos); public int setScrollRange(int min, int max); public void setStyle(int style); public int setXPosition(int x); public int setYPosition(int y); public int scrollEnd(); public int scrollHome(); public int scrollLineDown(); public int scrollLineUp(); public int scrollPageDown(); public int scrollPageUp(); public boolean action(Event e, Object o); public boolean mouseDrag(Event e, int x, int y); public boolean mouseDown(Event e, int x, int y); public boolean mouseUp(Event e, int x, int y); }
A class that implements a scroll track control. UIScroll defines three scroll track styles: VERTICAL, NOHIDE, and NOSHOW. (By default, the scroll track is horizontal and is only displayed when its range and page values allow scrolling.) The following example shows how to construct a scroll track control using the defined styles.
// Construct a vertical scroll track that is always visible. UIScroll sc = new UIScroll(UIScroll.VERTICAL | UIScroll.NOHIDE);
UIScroll manages three components, identified by the following layout indices.
Layout Index | Component |
THUMB | The component used to indicate the current position of the scroll track control (by default, a UIScrollThumb object). |
PAGE_UP | The track area above or to the left of the thumb component (by default, a UIRepeatButton object). |
PAGE_DOWN | The track area below or to the right of the thumb component (by default, a UIRepeatButton object). |
Note that UIScrollBar extends UIScroll to implement a scroll bar control. UIScrollBar adds the LINE_UP and LINE_DOWN components to the ends of the scroll track.
public UIScroll();Creates a horizontal scroll track control. By default, the scroll track has a range of 0 to 100.
public UIScroll(int style);Creates a scroll track control with the specified style. By default, the scroll track has a range of 0 to 100.
Parameter Description style The style of the scroll track. Specify one of the following values: If an undefined style is specified, an IllegalArgumentException is thrown.
public UIScroll(int style, int min, int max, int page, int line, int pos);Creates a scroll track control with the specified style and scroll information.
Parameter Description style The style of the scroll track control. Specify one of the following values: If an undefined style is specified, an IllegalArgumentException is thrown.
min The minimum value in the scroll track's range. max The maximum value in the scroll track's range. page The number of scroll positions associated with a full page. The size of the THUMB component is based on the ratio of page to range. line The number of pixels associated with a scroll position. pos The current position of the scroll track control within its range.
public boolean action(Event e, Object o);Responds to action events sent from the scroll track control's components.
Return Value:
Returns true if the event was handled; otherwise, returns false.
Parameter Description event The event posted to the scroll track control. object The object that posted the event. Remarks:
This method updates the control's position, based on one of the following actions.
public Component add(int index, Component 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.
Parameter Description index The layout index of the component to be added. Specify either THUMB, PAGE_UP, or PAGE_DOWN. If an undefined index is passed, an IllegalArgumentException is thrown. comp The component to be added.
public Color getBackground();Retrieves the background color of the scroll track control.
Return Value:
Returns a Color object containing the control's background color. The color returned is darker if the control is currently tracked.
public Component getLayoutComponent(int index);Retrieves the component at the specified layout index.
Return Value:
Returns the specified component, or null if no such component exists.
Parameter Description name The layout index of the component to be retrieved. Specify either THUMB, PAGE_UP, or PAGE_DOWN. If an undefined index is passed, an IllegalArgumentException is thrown.
public Point getPosition();Retrieves the position of the scroll track control.
Return Value:
Returns a Point object containing the current position.
Remarks:
If the scroll track is horizontal, the x coordinate of the returned Point is the current scroll position, and the y coordinate is zero. If the scroll track is vertical, the x coordinate is zero and the y coordinate is the current scroll position.
public int getRoleCode();Retrieves the role of the scroll track control.
Return Value:
Returns the ROLE_SYSTEM code that best describes the role of the control.
Remarks:
This method returns the ROLE_SYSTEM_SCROLLBAR code.
public int getScrollLine();Retrieves the number of pixels associated with a scroll position.
Return Value:
Returns the number of pixels in a scroll line.
public int getScrollMax();Retrieves the maximum value in the scroll track's range.
Return Value:
Returns the maximum range value.
public int getScrollMin();Retrieves the minimum value in the scroll track's range.
Return Value:
Returns the minimum range value.
public int getScrollPage();Retrieves the number of scroll positions associated with a page.
Return Value:
Returns the number of scroll positions in a page.
public int getScrollPos();Retrieves the current position of the scroll track control.
Return Value:
Returns the control's position within its range.
public int getStyle();Retrieves the current style of the scroll track control.
Return Value:
Returns an integer containing the current style settings. For a list of possible styles, see setStyle.
public int getXPosition();Retrieves the horizontal scroll position of the scroll track control.
Return Value:
Returns the current scroll position, if the control is horizontal; otherwise, returns 0.
public int getYPosition();Retrieves the vertical scroll position of the scroll track control.
Return Value:
Returns the current scroll position, if the control is vertical; otherwise, returns 0.
public void initGraphics();Called to perform initialization when the graphics context is first available.
Return Value:
No return value.
Remarks:
This method adds the THUMB, PAGE_UP, and PAGE_DOWN components to the scroll track control.
public boolean isScrollable();Determines whether the control must scroll, based on its range and page specifications.
Return Value:
Returns true if the control must scroll; otherwise, returns false.
Remarks:
If the scroll track control has the NOHIDE style, it will be disabled if scrolling is not necessary. Otherwise, if the NOSHOW style is set, or if scrolling is not necessary, the control will be hidden.
public void layout();Lays out the components of the scroll track control.
Return Value:
No return value.
Remarks:
If the scroll track control has the NOHIDE style, it will be disabled if scrolling is not necessary. Otherwise, if the NOSHOW style is set, or if scrolling is not necessary, the control will be hidden.
public Dimension minimumSize();Determines the minimum size (in pixels) of the scroll track control.
Return Value:
Returns a Dimension object containing the minimum size.
Remarks:
The control's minimum size is based on the minimum size of each of its components.
public boolean mouseDown(Event e, int x, int y);Reacts to the mouse button being pressed by setting the pressed state of this object.
Return Value:
Returns false.
Parameter Description e The event posted to the control. x The x coordinate of the event. y The y coordinate of the event.
public boolean mouseDrag(Event e, int x, int y);Responds to mouse drag event sent from the Thumb component of the scroll track control.
Parameter Description event The event posted to the control. x The x coordinate of the event. y The x coordinate of the event.
public boolean mouseUp(Event e, int x, int y);Reacts to the mouse button being released by clearing the pressed state of this object.
Return Value:
Returns false.
Parameter Description e The event posted to the control. x The x coordinate of the event. y The y coordinate of the event.
public Dimension preferredSize();Determines the preferred size (in pixels) of the scroll track control.
Return Value:
Returns a Dimension object containing the preferred size.
Remarks:
The control's preferred size is based on the preferred size of each of its components.
public void reshape(int x, int y, int width, int height);Reshapes the scroll track control to the specified dimensions within its parent's coordinate space.
Return Value:
No return value.
Parameter Description x The x coordinate of the control's top-left corner. y The y coordinate of the control's top-left corner. width The width of the control. height The height of the control. Remarks:
After reshaping the scroll track control, this method validates the control to update the layout of its components.
public int scrollEnd();Moves the current scroll position to the maximum range value.
Return Value:
Returns the control's new scroll position.
public int scrollHome();Moves the current scroll position to the minimum range value.
Return Value:
Returns the control's new scroll position.
public int scrollLineDown();Moves the current scroll position down or right by one line.
Return Value:
Returns the control's new scroll position.
public int scrollLineUp();Moves the current scroll position up or left by one line.
Return Value:
Returns the control's new scroll position.
public int scrollPageDown();Moves the current scroll position down or right by one scroll position less than a full page.
Return Value:
Returns the control's new scroll position.
public int scrollPageUp();Moves the current scroll position up or left by one scroll position less than a full page.
Return Value:
Returns the control's new scroll position.
public Point setPosition(Point pt);Repositions the scroll track control, based on the specified Point.
Return Value:
Returns a Point object containing the new position.
Parameter Description pt The requested position for the scroll track control. The x and y coordinates specify the horizontal and vertical scroll positions, respectively. Remarks:
If the scroll track is horizontal, the x coordinate of the returned Point is the current scroll position, and the y coordinate is zero. If the scroll track is vertical, the x coordinate is zero and the y coordinate is the current scroll position. Depending on the control's range, these coordinates may differ from those of the parameter pt.
public Point setPosition(int x, int y);Repositions the scroll track control, based on the specified scroll positions.
Return Value:
Returns a Point object containing the new position.
Parameter Description x The requested horizontal scroll position. y The requested vertical scroll position. Remarks:
If the scroll track is horizontal, the x coordinate of the returned Point is the current scroll position, and the y coordinate is zero. If the scroll track is vertical, the x coordinate is zero and the y coordinate is the current scroll position. Depending on the control's range, these coordinates may differ from the x and y parameters.
public int setScrollInfo(int min, int max, int page, int line, int pos);Sets the specified scroll information and repositions the scroll track control accordingly.
Return Value:
Returns the control's new scroll position after setting the specified values.
Parameter Description min The minimum value in the scroll track's range. max The maximum value in the scroll track's range. page The number of scroll positions associated with a full page. The size of the THUMB component is based on the ratio of page to range. line The number of pixels associated with a scroll position. pos The current position of the scroll track control within its range.
public int setScrollLine(int line);Sets the number of pixels associated with a scroll position, and repositions the scroll track control accordingly.
Return Value:
Returns the control's new scroll position after setting the specified value.
Parameter Description line The number of pixels to be associated with a scroll position.
public int setScrollMax(int max);Sets the maximum range value and repositions the scroll track control accordingly.
Return Value:
Returns the control's new scroll position after setting the specified value.
Parameter Description max The maximum value for the scroll track's range.
public int setScrollMin(int min);Sets the minimum range value and repositions the scroll track control accordingly.
Return Value:
Returns the control's new scroll position after setting the specified value.
Parameter Description min The minimum value for the scroll track's range.
public int setScrollPage(int page);Sets the number of scroll positions associated with a full page, and repositions the scroll track control accordingly.
Return Value:
Returns the control's new scroll position after setting the specified value.
Parameter Description page The number of scroll positions to be associated with a full page. The size of the THUMB component is based on the ratio of page to range.
public int setScrollPos(int pos);Repositions the scroll track control, based on the specified scroll position.
Return Value:
Returns the control's new scroll position after setting the specified value.
Parameter Description pos The position for the scroll track control. Remarks:
Depending on the control's range, the returned position may differ from the pos parameter.
public int setScrollRange(int min, int max);Sets the scroll track control's range, and repositions the control accordingly.
Return Value:
Returns the control's new scroll position after setting the specified values.
Parameter Description min The minimum value for the scroll track's range. max The maximum value for the scroll track's range.
public void setStyle(int style);Sets the current style for the scroll track control.
Parameter Description style The style of the scroll track control. Specify one of the following values: If an undefined style is specified, an IllegalArgumentException is thrown.
public int setXPosition(int x);Sets the horizontal scroll position of the control.
Return Value:
Returns the control's new scroll position, if the control is horizontal; otherwise, returns 0.
Parameter Description x The requested horiziontal scroll position. Remarks:
If the scroll track is horizontal, the returned position may differ from the x parameter, depending on the control's range.
public int setYPosition(int y);Sets the vertical scroll position of the control.
Return Value:
Returns the control's new scroll position, if the control is vertical; otherwise, returns 0.
Parameter Description y The requested vertical scroll position. Remarks:
If the scroll track is vertical, the returned position may differ from the y parameter, depending on the control's range.
© 1997 Microsoft Corporation. All rights reserved. Legal Notices.