本文介绍了GWT CustomScrollPanel示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解了GWT的CustomScrollPanel以及如何自定义滚动条,但我找不到任何示例或如何设置它。

解决方案

这是您如何定制原生滚动条的方式,不过您还可以开发自己的滚动条类,它们实现了VerticalScrollbar和Horizo​​ntalScrollbar,这些类可以进行更多的自定义。

资源(样式)定义:

  code $:b 
$ b $ pre code $ CustomScrollPanel csp = new CustomScrollPanel((ScrollResourcesContainer.ScrollPanelResources)GWT.create(ScrollResourcesContainer.ScrollPanelResources.class ));
csp.setHorizo​​ntalScrollbar(新的NativeHorizo​​ntalScrollbar((Horizo​​ntalResources)GWT.create(Horizo​​ntalResources.class)),
AbstractNativeScrollbar.getNativeScrollbarHeight());
csp.setVerticalScrollbar(新的NativeVerticalScrollbar((VerticalResources)GWT.create(VerticalResources.class)),
AbstractNativeScrollbar.getNativeScrollbarWidth());


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 that show custom scrollbars in use?

解决方案

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());

这篇关于GWT CustomScrollPanel示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 03:42