Class Scrollbar

All Implemented Interfaces:
HasAttachHandlers, HasHandlers, EventListener, HasVisibility, IsWidget, LogicalStructure, HasClearHandlers, HasClickHandlers, HasDoubleClickHandlers, HasDragMoveHandlers, HasDragRepositionMoveHandlers, HasDragRepositionStartHandlers, HasDragRepositionStopHandlers, HasDragResizeMoveHandlers, HasDragResizeStartHandlers, HasDragResizeStopHandlers, HasDragStartHandlers, HasDragStopHandlers, HasDropHandlers, HasDropMoveHandlers, HasDropOutHandlers, HasDropOverHandlers, HasFocusChangedHandlers, HasHoverHandlers, HasHoverHiddenHandlers, HasKeyDownHandlers, HasKeyPressHandlers, HasMouseDownHandlers, HasMouseMoveHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseStillDownHandlers, HasMouseUpHandlers, HasMouseWheelHandlers, HasMovedHandlers, HasParentMovedHandlers, HasResizedHandlers, HasRightMouseDownHandlers, HasRuleContextChangedHandlers, HasScrolledHandlers, HasShowContextMenuHandlers, HasVisibilityChangedHandlers

public class Scrollbar extends StretchImg
The Scrollbar widget implements cross-platform, image-based scrollbars that control the scrolling of content in other widgets. Scrollbar widgets are created and displayed automatically for widgets that require them, based on settings for Canvas.overflow.

The scrollbar's appearance is based on a StretchImg for the "track", which consists of two fixed size buttons and a stretchable center segment, and the ScrollThumb, the draggable portion of the scrollbar, also a StretchImg, with an optional grip.

  • Constructor Details

    • Scrollbar

      public Scrollbar()
    • Scrollbar

      public Scrollbar(JavaScriptObject jsObj)
  • Method Details

    • getOrCreateRef

      public static Scrollbar getOrCreateRef(JavaScriptObject jsObj)
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, Canvas defaults)
      Changes the defaults for Canvas AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - Canvas defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, FormItem defaults)
      Changes the defaults for FormItem AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - FormItem defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • create

      protected JavaScriptObject create()
      Overrides:
      create in class StretchImg
    • setAllowThumbDownState

      public Scrollbar setAllowThumbDownState(Boolean allowThumbDownState) throws IllegalStateException
      If true, the thumb's appearance changes when it's clicked on.

      Note : This is an advanced setting

      Parameters:
      allowThumbDownState - New allowThumbDownState value. Default value is false
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getAllowThumbDownState

      public Boolean getAllowThumbDownState()
      If true, the thumb's appearance changes when it's clicked on.
      Returns:
      Current allowThumbDownState value. Default value is false
    • setAllowThumbOverState

      public Scrollbar setAllowThumbOverState(Boolean allowThumbOverState) throws IllegalStateException
      If true, the thumb's appearance changes when the user rolls over it.

      Note : This is an advanced setting

      Parameters:
      allowThumbOverState - New allowThumbOverState value. Default value is false
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getAllowThumbOverState

      public Boolean getAllowThumbOverState()
      If true, the thumb's appearance changes when the user rolls over it.
      Returns:
      Current allowThumbOverState value. Default value is false
    • setAutoEnable

      public Scrollbar setAutoEnable(Boolean autoEnable)
      If true, this scrollbar will automatically enable when the scrollTarget is scrollable (i.e., when the contents of the scrollTarget exceed its clip size in the direction relevant to this scrollbar), and automatically disable when the scrollTarget is not scrollable. Set this property to false for full manual control over a scrollbar's enabled state.

      Note : This is an advanced setting

      Parameters:
      autoEnable - New autoEnable value. Default value is true
      Returns:
      Scrollbar instance, for chaining setter calls
    • getAutoEnable

      public Boolean getAutoEnable()
      If true, this scrollbar will automatically enable when the scrollTarget is scrollable (i.e., when the contents of the scrollTarget exceed its clip size in the direction relevant to this scrollbar), and automatically disable when the scrollTarget is not scrollable. Set this property to false for full manual control over a scrollbar's enabled state.
      Returns:
      Current autoEnable value. Default value is true
    • setBtnSize

      public Scrollbar setBtnSize(Integer btnSize)
      The size of the square buttons (arrows) at the ends of this scrollbar. This overrides Canvas.scrollbarSize to set the width of a vertical scrollbar or the height of a horizontal scrollbar. If not set it will default to Canvas.scrollbarSize.
      Parameters:
      btnSize - New btnSize value. Default value is null
      Returns:
      Scrollbar instance, for chaining setter calls
    • getBtnSize

      public Integer getBtnSize()
      The size of the square buttons (arrows) at the ends of this scrollbar. This overrides Canvas.scrollbarSize to set the width of a vertical scrollbar or the height of a horizontal scrollbar. If not set it will default to Canvas.scrollbarSize.
      Returns:
      Current btnSize value. Default value is null
    • setCornerImg

      public Scrollbar setCornerImg(StretchItem cornerImg) throws IllegalStateException
      The StretchItem for the corner between vertical and horizontal scrollbars. The width and height are determined automatically, so StretchItem.width and StretchItem.height set on the cornerImg StretchItem are ignored. The default is: new StretchItem("corner", null, null)
      Parameters:
      cornerImg - New cornerImg value. Default value is see below
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getCornerImg

      public StretchItem getCornerImg()
      The StretchItem for the corner between vertical and horizontal scrollbars. The width and height are determined automatically, so StretchItem.width and StretchItem.height set on the cornerImg StretchItem are ignored. The default is: new StretchItem("corner", null, null)
      Returns:
      Current cornerImg value. Default value is see below
    • setCornerSize

      public Scrollbar setCornerSize(Integer cornerSize) throws IllegalStateException
      Allows the size of the corner segment to be set independently of the btnSize.
      Parameters:
      cornerSize - New cornerSize value. Default value is null
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getCornerSize

      public Integer getCornerSize()
      Allows the size of the corner segment to be set independently of the btnSize.
      Returns:
      Current cornerSize value. Default value is null
    • setCornerSrc

      public Scrollbar setCornerSrc(String cornerSrc) throws IllegalStateException
      URL for the corner image, a singular image that appears in the corner when both h and v scrollbars are showing.
      Parameters:
      cornerSrc - New cornerSrc value. Default value is "[SKIN]corner.gif"
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getCornerSrc

      public String getCornerSrc()
      URL for the corner image, a singular image that appears in the corner when both h and v scrollbars are showing.
      Returns:
      Current cornerSrc value. Default value is "[SKIN]corner.gif"
      See Also:
    • setEndImg

      public Scrollbar setEndImg(StretchItem endImg) throws IllegalStateException
      The StretchItem for the end of a scrollbar (the "scroll down" or "scroll right" button image). The default is: new StretchItem("end", "btnSize", "btnSize")
      Parameters:
      endImg - New endImg value. Default value is see below
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getEndImg

      public StretchItem getEndImg()
      The StretchItem for the end of a scrollbar (the "scroll down" or "scroll right" button image). The default is: new StretchItem("end", "btnSize", "btnSize")
      Returns:
      Current endImg value. Default value is see below
    • setEndThumbOverlap

      public Scrollbar setEndThumbOverlap(Integer endThumbOverlap) throws IllegalStateException
      Number of pixels the thumb is allowed to overlap the buttons at the end of the track. Default prevents doubling of 1px borders. Set higher to allow media that shows curved joins between the track button and ScrollThumb.

      Note : This is an advanced setting

      Parameters:
      endThumbOverlap - New endThumbOverlap value. Default value is null
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getEndThumbOverlap

      public Integer getEndThumbOverlap()
      Number of pixels the thumb is allowed to overlap the buttons at the end of the track. Default prevents doubling of 1px borders. Set higher to allow media that shows curved joins between the track button and ScrollThumb.
      Returns:
      Current endThumbOverlap value. Default value is null
    • setHSrc

      public Scrollbar setHSrc(String hSrc) throws IllegalStateException
      Base URL for the images used for the horizontal scrollbar track and end buttons.

      See StretchImg.items for a general explanation of how this base URL is transformed into various pieces and states.

      For a normal 3-segment track, the suffixes "_start", "_track" and "_end" are added to this URL. The "start" and "end" images should appear to be buttons (the user can click on these segments to scroll slowly). The "track" segment provides a background for the space in which the thumb can be dragged, and can also be clicked on to scroll quickly.

      For a 5-segment track (showTrackEnds:true), the suffixes are "_start", "_track_start", "_track", "_track_end" and "_end".

      Overrides:
      setHSrc in class StretchImg
      Parameters:
      hSrc - New hSrc value. Default value is "[SKIN]hscroll.gif"
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getHSrc

      public String getHSrc()
      Base URL for the images used for the horizontal scrollbar track and end buttons.

      See StretchImg.items for a general explanation of how this base URL is transformed into various pieces and states.

      For a normal 3-segment track, the suffixes "_start", "_track" and "_end" are added to this URL. The "start" and "end" images should appear to be buttons (the user can click on these segments to scroll slowly). The "track" segment provides a background for the space in which the thumb can be dragged, and can also be clicked on to scroll quickly.

      For a 5-segment track (showTrackEnds:true), the suffixes are "_start", "_track_start", "_track", "_track_end" and "_end".

      Overrides:
      getHSrc in class StretchImg
      Returns:
      Current hSrc value. Default value is "[SKIN]hscroll.gif"
      See Also:
    • setScrollTarget

      public Scrollbar setScrollTarget(Canvas scrollTarget)
      The widget whose contents should be scrolled by this scrollbar. The scrollbar thumb is sized according to the amount of visible vs. scrollable content in this widget.

      If this method is called after the component has been drawn/initialized: Sets or clears the scrollbar's scrollTarget. If no argument is provided, then the scrollTarget will be set to the scrollbar itself.

      Note : This is an advanced setting

      Parameters:
      scrollTarget - target canvas to be scrolled. Default value is null
      Returns:
      Scrollbar instance, for chaining setter calls
    • getScrollTarget

      public Canvas getScrollTarget()
      The widget whose contents should be scrolled by this scrollbar. The scrollbar thumb is sized according to the amount of visible vs. scrollable content in this widget.
      Returns:
      Current scrollTarget value. Default value is null
    • setShowCorner

      public Scrollbar setShowCorner(Boolean showCorner) throws IllegalStateException
      If true, displays a corner piece at the bottom end of a vertical scrollbar, or the right end of a horizontal scrollbar. This is typically set only when both horizontal and vertical scrollbars are displayed and about the same corner.

      Note : This is an advanced setting

      Parameters:
      showCorner - New showCorner value. Default value is false
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getShowCorner

      public Boolean getShowCorner()
      If true, displays a corner piece at the bottom end of a vertical scrollbar, or the right end of a horizontal scrollbar. This is typically set only when both horizontal and vertical scrollbars are displayed and about the same corner.
      Returns:
      Current showCorner value. Default value is false
    • setShowTrackButtons

      public Scrollbar setShowTrackButtons(Boolean showTrackButtons) throws IllegalStateException
      Should the track buttons that allow page scrolling be shown?

      Note : This is an advanced setting

      Parameters:
      showTrackButtons - New showTrackButtons value. Default value is true
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getShowTrackButtons

      public Boolean getShowTrackButtons()
      Should the track buttons that allow page scrolling be shown?

      Returns:
      Current showTrackButtons value. Default value is true
    • setShowTrackEnds

      public Scrollbar setShowTrackEnds(Boolean showTrackEnds) throws IllegalStateException
      If true, the scrollbar uses a 5-segment rather than 3-segment image representation, where the 3 interior image segments have the same state (Down, Over, etc), independent of the two outermost image segments.

      This allows certain advanced skinning designs where the track-as-such (space in which the thumb may be dragged) has curved endcaps, and is also visually stateful (that is, changes when the mouse goes down, without affecting the appearance of the outermost segments).

      Note : This is an advanced setting

      Parameters:
      showTrackEnds - New showTrackEnds value. Default value is false
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getShowTrackEnds

      public Boolean getShowTrackEnds()
      If true, the scrollbar uses a 5-segment rather than 3-segment image representation, where the 3 interior image segments have the same state (Down, Over, etc), independent of the two outermost image segments.

      This allows certain advanced skinning designs where the track-as-such (space in which the thumb may be dragged) has curved endcaps, and is also visually stateful (that is, changes when the mouse goes down, without affecting the appearance of the outermost segments).

      Returns:
      Current showTrackEnds value. Default value is false
    • setSkinImgDir

      public Scrollbar setSkinImgDir(String skinImgDir) throws IllegalStateException
      Where are the skin images for the Scrollbar. This is local to the overall skin directory.

      Note : This is an advanced setting

      Overrides:
      setSkinImgDir in class Canvas
      Parameters:
      skinImgDir - New skinImgDir value. Default value is "images/Scrollbar/"
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getSkinImgDir

      public String getSkinImgDir()
      Where are the skin images for the Scrollbar. This is local to the overall skin directory.
      Overrides:
      getSkinImgDir in class Canvas
      Returns:
      Current skinImgDir value. Default value is "images/Scrollbar/"
      See Also:
    • setStartImg

      public Scrollbar setStartImg(StretchItem startImg) throws IllegalStateException
      The StretchItem for the start of a scrollbar (the "scroll up" or "scroll left" button image). The default is: new StretchItem("start", "btnSize", "btnSize")
      Parameters:
      startImg - New startImg value. Default value is see below
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getStartImg

      public StretchItem getStartImg()
      The StretchItem for the start of a scrollbar (the "scroll up" or "scroll left" button image). The default is: new StretchItem("start", "btnSize", "btnSize")
      Returns:
      Current startImg value. Default value is see below
    • setStartThumbOverlap

      public Scrollbar setStartThumbOverlap(Integer startThumbOverlap) throws IllegalStateException
      Number of pixels the thumb is allowed to overlap the buttons at the start of the track. Default prevents doubling of 1px borders. Set higher to allow media that shows curved joins between the track button and ScrollThumb.

      Note : This is an advanced setting

      Parameters:
      startThumbOverlap - New startThumbOverlap value. Default value is null
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getStartThumbOverlap

      public Integer getStartThumbOverlap()
      Number of pixels the thumb is allowed to overlap the buttons at the start of the track. Default prevents doubling of 1px borders. Set higher to allow media that shows curved joins between the track button and ScrollThumb.
      Returns:
      Current startThumbOverlap value. Default value is null
    • setThumbInset

      public Scrollbar setThumbInset(Integer thumbInset) throws IllegalStateException
      Inset of the thumb relative to the track. An inset of N pixels means the thumb is 2N pixels smaller in breadth than the track.

      Note : This is an advanced setting

      Parameters:
      thumbInset - New thumbInset value. Default value is null
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getThumbInset

      public Integer getThumbInset()
      Inset of the thumb relative to the track. An inset of N pixels means the thumb is 2N pixels smaller in breadth than the track.
      Returns:
      Current thumbInset value. Default value is null
    • setThumbMinSize

      public Scrollbar setThumbMinSize(int thumbMinSize) throws IllegalStateException
      The minimum pixel size of the draggable thumb regardless of how large the scrolling region becomes.

      Note : This is an advanced setting

      Parameters:
      thumbMinSize - New thumbMinSize value. Default value is 12
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getThumbMinSize

      public int getThumbMinSize()
      The minimum pixel size of the draggable thumb regardless of how large the scrolling region becomes.
      Returns:
      Current thumbMinSize value. Default value is 12
    • setThumbOverlap

      public Scrollbar setThumbOverlap(int thumbOverlap) throws IllegalStateException
      Number of pixels the thumb is allowed to overlap the buttons at each end of the track. Default prevents doubling of 1px borders. Set higher to allow media that shows curved joins between the track button and ScrollThumb.

      Note : This is an advanced setting

      Parameters:
      thumbOverlap - New thumbOverlap value. Default value is 1
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getThumbOverlap

      public int getThumbOverlap()
      Number of pixels the thumb is allowed to overlap the buttons at each end of the track. Default prevents doubling of 1px borders. Set higher to allow media that shows curved joins between the track button and ScrollThumb.
      Returns:
      Current thumbOverlap value. Default value is 1
    • setTrackEndHeight

      public Scrollbar setTrackEndHeight(int trackEndHeight) throws IllegalStateException
      The minimum pixel height of the track end segments (if enabled with showTrackEnds).

      Note : This is an advanced setting

      Parameters:
      trackEndHeight - New trackEndHeight value. Default value is 12
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getTrackEndHeight

      public int getTrackEndHeight()
      The minimum pixel height of the track end segments (if enabled with showTrackEnds).
      Returns:
      Current trackEndHeight value. Default value is 12
    • setTrackEndImg

      public Scrollbar setTrackEndImg(StretchItem trackEndImg) throws IllegalStateException
      The StretchItem for the end of a scrollbar track. The default is: new StretchItem("track_end", "trackEndSize", "trackEndSize")
      Parameters:
      trackEndImg - New trackEndImg value. Default value is see below
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getTrackEndImg

      public StretchItem getTrackEndImg()
      The StretchItem for the end of a scrollbar track. The default is: new StretchItem("track_end", "trackEndSize", "trackEndSize")
      Returns:
      Current trackEndImg value. Default value is see below
    • setTrackEndWidth

      public Scrollbar setTrackEndWidth(int trackEndWidth) throws IllegalStateException
      The minimum pixel width of the track end segments (if enabled with showTrackEnds).

      Note : This is an advanced setting

      Parameters:
      trackEndWidth - New trackEndWidth value. Default value is 12
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getTrackEndWidth

      public int getTrackEndWidth()
      The minimum pixel width of the track end segments (if enabled with showTrackEnds).
      Returns:
      Current trackEndWidth value. Default value is 12
    • setTrackImg

      public Scrollbar setTrackImg(StretchItem trackImg) throws IllegalStateException
      The StretchItem for the middle part of a scrollbar track, which usually takes up the majority of the width or height of the scrollbar. The default is: new StretchItem("track", "*", "*")
      Parameters:
      trackImg - New trackImg value. Default value is see below
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getTrackImg

      public StretchItem getTrackImg()
      The StretchItem for the middle part of a scrollbar track, which usually takes up the majority of the width or height of the scrollbar. The default is: new StretchItem("track", "*", "*")
      Returns:
      Current trackImg value. Default value is see below
    • setTrackStartImg

      public Scrollbar setTrackStartImg(StretchItem trackStartImg) throws IllegalStateException
      The StretchItem for the start of a scrollbar track. The default is: new StretchItem("track_start", "trackStartSize", "trackStartSize")
      Parameters:
      trackStartImg - New trackStartImg value. Default value is see below
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getTrackStartImg

      public StretchItem getTrackStartImg()
      The StretchItem for the start of a scrollbar track. The default is: new StretchItem("track_start", "trackStartSize", "trackStartSize")
      Returns:
      Current trackStartImg value. Default value is see below
    • setVSrc

      public Scrollbar setVSrc(String vSrc) throws IllegalStateException
      Base URL for the images used for the vertical scrollbar track and end buttons. See hSrc for usage.
      Overrides:
      setVSrc in class StretchImg
      Parameters:
      vSrc - New vSrc value. Default value is "[SKIN]vscroll.gif"
      Returns:
      Scrollbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getVSrc

      public String getVSrc()
      Base URL for the images used for the vertical scrollbar track and end buttons. See hSrc for usage.
      Overrides:
      getVSrc in class StretchImg
      Returns:
      Current vSrc value. Default value is "[SKIN]vscroll.gif"
      See Also:
    • setDefaultProperties

      public static void setDefaultProperties(Scrollbar scrollbarProperties)
      Class level method to set the default properties of this class. If set, then all existing and subsequently created instances of this class will automatically have default properties corresponding to the properties set on the SmartGWT class instance passed to this function before its underlying SmartClient JS object was created. This is a powerful feature that eliminates the need for users to create a separate hierarchy of subclasses that only alter the default properties of this class. Can also be used for skinning / styling purposes.

      Note: This method is intended for setting default attributes only and will affect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead. Calling this method after instances have been created can result in undefined behavior, since it bypasses any setters and a class instance may have already examined a particular property and not be expecting any changes through this route.

      Parameters:
      scrollbarProperties - properties that should be used as new defaults when instances of this class are created
      See Also:
    • preloadImages

      public static void preloadImages()
      Preload primary Scrollbar skin images.
    • setLogicalStructure

      public LogicalStructureObject setLogicalStructure(ScrollbarLogicalStructure s)
      Setter implementing the LogicalStructure interface, which supports Eclipse's logical structure debugging facility.
    • getLogicalStructure

      public LogicalStructureObject getLogicalStructure()
      Getter implementing the LogicalStructure interface, which supports Eclipse's logical structure debugging facility.
      Specified by:
      getLogicalStructure in interface LogicalStructure
      Overrides:
      getLogicalStructure in class StretchImg