To convert from AWT to AFC, instances of java.awt.ScrollPane should be transformed into instances of com.ms.UI.UIScrollViewer.
ScrollPane extends Container: be sure to see its changes.
UIScrollViewer gives you more control over scrollable areas. First, besides setting the increments of scrollbars, you can also position the scrollbars on whichever side you choose, like
new UIScrollViewer(myList, 15, 15, UIScrollViewer.SCROLL_TOP);
As in AWT, you can also decide to always display the scroll bar (NOHIDE) or always hide it (NOSHOW). You can also make it so that the size of the scroll bar's thumb component is not proportional to the scroll bar's range (NONPROPORTIONAL). This can be done separately for each scrollbar: the construction
new UIScrollViewer(myTree, 15, 15, UIScrollViewer.SCROLL_TOP, UIScroll.NOHIDE, UIScroll.NOSHOW);
always displays the horizontal scrollbar and never displays the vertical scrollbar.
Finally, you can move the header bar to the bottom or the right, rather than the default left or top.
This is the set of changes you need to make to port all ScrollPane methods to UIScrollViewer methods. Any method not listed here or below does not need to be changed.
AWT Code | AFC Code | Comments |
ScrollPane() or ScrollPane(int) |
UIScrollViewer()
or UIScrollViewer(Component) or UIScrollViewer(Component, int) |
You cannot specify a scrollbar with just a style: if you include a style, you must also include the component kept in the UIScrollViewer. There are other constructors to include more styles: see the documentation for more information. |
SCROLLBARS_AS_NEEDED | 0 | Default setting |
SCROLLBARS_NEVER | UIScroll.NOSHOW | |
SCROLLBARS_ALWAYS | UIScroll.NOHIDE | |
addImpl(Component, Object, int) | setContent(UIComponent) | addImpl ignores the Object and uses an integer for placement, which plays no role in ScrollPane: setContent does the same thing, changing the component and returning the old one. |
getScrollPosition() | getPosition() | |
layout() | doLayout() | Deprecated in AWT 1.1 |
printComponents(Graphics) | printAll(Graphics) | |
setScrollPosition(int, int) | setPosition(int, int) | |
setScrollPosition(point) | setPosition(point) |
Some methods in java.awt.ScrollPane are not directly supported in com.ms.ui.UIScrollViewer. Those methods and suggested changes are described here.
AWT Code/Suggested AFC Code | Comments |
getHAdjustable() getXPosition() |
AWT returns an adjustable object, and AFC returns an int. |
getHScrollbarHeight() (no suggestions) |
|
getScrollbarDisplayPolicy() (no suggestions) |
|
getViewportSize() (no suggestions) |
|
getVScrollbarWidth() (no suggestions) |
|
paramString() getName(), etc. |
Use the appropriate getXXX function to get the information you need. |
setLayout(LayoutManager) (no suggestions) |
You can't change a scrollbar's layout manager. |