繁体   English   中英

自定义CustomScrollPanel ScrollBars?

[英]Customize CustomScrollPanel ScrollBars?

我想自定义CustomScrollPanel的滚动条。 我想自定义滚动条,并且要分别启用和禁用垂直和水平滚动条。

这是MyScrollPanel:

public class MyScrollPanel extends Composite implements HasWidgets {

    public interface ScrollPanelResources extends CustomScrollPanel.Resources
    {
        @Override
        @Source( { "test/web/client/widgets/ScrollPanel.css", CustomScrollPanel.Style.DEFAULT_CSS } )
        CustomScrollPanel.Style customScrollPanelStyle();
    }

    public interface HorizontalResources extends NativeHorizontalScrollbar.Resources
    {
        @Override
        @Source( { "test/web/client/widgets/HorizontalScrollbar.css", NativeHorizontalScrollbar.StyleTransparant.DEFAULT_CSS } )
        NativeHorizontalScrollbar.Style nativeHorizontalScrollbarStyle();
    }

    public interface VerticalResources extends NativeVerticalScrollbar.Resources
    {
        @Override
        @Source( { "test/web/client/widgets/VerticalScrollbar.css", NativeVerticalScrollbar.StyleTransparant.DEFAULT_CSS } )
        NativeVerticalScrollbar.Style nativeVerticalScrollbarStyle();
    }

    public interface Resources extends ClientBundle {

        @Source({"test/web/client/widgets/MyScrollPanel.css"})
        Css css();
    }

    public interface Css extends CssResource, AppCss {

        String resizeLayoutPanel();
        String customScrollPanel();

    }

    Resources resources;


    private ResizeLayoutPanel resizeLayoutPanel;
    private CustomScrollPanel customScrollPanel;


    public MyScrollPanel() {
        resources = GWT.create(Resources.class);
        resources.css().ensureInjected();
        resizeLayoutPanel = new ResizeLayoutPanel();
        resizeLayoutPanel.setStyleName(resources.css().resizeLayoutPanel());


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

        customScrollPanel.addStyleName(resources.css().customScrollPanel());


        resizeLayoutPanel.add(customScrollPanel);
        initWidget(resizeLayoutPanel);
    }


    @Override
    public void add(Widget w) {
        customScrollPanel.add(w);
    }


    @Override
    public void clear() {
        customScrollPanel.clear();
    }


    @Override
    public Iterator<Widget> iterator() {
        return customScrollPanel.iterator();
    }


    @Override
    public boolean remove(Widget w) {
        return customScrollPanel.remove(w);
    }




}

我发现了这个帖子GWT CustomScrollPanel示例,但是它不能解决问题。

如何自定义滚动条并分别启用和禁用垂直和水平滚动条?

如何设置自定义滚动条的样式?

CustomScrollPanel提供了两种方法:

.getHorizontalScrollbar()
.getVerticalScrollbar()

然后,您可以在必要时显示/隐藏它们,或应用所需的任何CSS。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM