GWT CustomScrollPanel example

前端 未结 3 388
[愿得一人]
[愿得一人] 2020-12-06 03:40

I found out about GWT\'s CustomScrollPanel and how you can customize the scroll bar, but I can\'t find any examples or how to set it up. Are there any examples out there th

3条回答
  •  粉色の甜心
    2020-12-06 04:13

    This is how you would customize the native scrollbars, however you could also develop your own scrollbar classes that implement VerticalScrollbar and HorizontalScrollbar that are a lot more customizable.

    Resource (style) definitions:

    public class ScrollResourcesContainer {
    
        public interface ScrollPanelResources extends CustomScrollPanel.Resources
        {
            @Override
            @Source( { "ScrollPanel.css", CustomScrollPanel.Style.DEFAULT_CSS } )
            CustomScrollPanel.Style customScrollPanelStyle();
        }
    
        public interface HorizontalResources extends NativeHorizontalScrollbar.Resources
        {
            @Override
            @Source( { "HorizontalScrollbar.css", NativeHorizontalScrollbar.StyleTransparant.DEFAULT_CSS } )
            NativeHorizontalScrollbar.Style nativeHorizontalScrollbarStyle();
        }
    
        public interface VerticalResources extends NativeVerticalScrollbar.Resources
        {
            @Override
            @Source( { "VerticalScrollbar.css", NativeVerticalScrollbar.StyleTransparant.DEFAULT_CSS } )
            NativeVerticalScrollbar.Style nativeVerticalScrollbarStyle();
        }
    }
    

    Usage through CustomScrollPanel :

        CustomScrollPanel csp = new CustomScrollPanel((ScrollResourcesContainer.ScrollPanelResources) GWT.create(ScrollResourcesContainer.ScrollPanelResources.class));
        csp.setHorizontalScrollbar(new NativeHorizontalScrollbar((HorizontalResources) GWT.create(HorizontalResources.class)),
        AbstractNativeScrollbar.getNativeScrollbarHeight());
        csp.setVerticalScrollbar(new NativeVerticalScrollbar((VerticalResources) GWT.create(VerticalResources.class)),
        AbstractNativeScrollbar.getNativeScrollbarWidth());
    

提交回复
热议问题