I want to customize the scrollbars of a CustomScrollPanel. I want to customize the scroll bars and I want to enable and disable the vertical and horizontal scrollbars separately.
This is 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);
}
}
I found this post GWT CustomScrollPanel example but it does not solve the problem.
How can I customize the scroll bars and enable and disable the vertical and horizontal scrollbars separately?
How can I style the custom scroll bars?