Google GWT SplitLayoutPanel: How to style the Splitters

I wanted to change the default style of the splitters of the new Google GWT SplitLayoutPanel. Unfortunately the height and the width of the VDragger and the HDragger are hardcoded. In the source code one can find the following comments:

 * NOTE: This class is still very new, and its interface
 * may change without warning. Use at your own risk.

and

* TODO(jgw):
 * - RTL Support.
 * - implement insert().
 * - Come up with a decent way to specify splitter style and size.

OK, I use it at my own risk and use a not so decent way to change the style of the splitters:

interface Binder extends UiBinder <SplitLayoutPanel, MyView> { }
private static Binder binder = GWT.create(Binder.class);
...
public MyView () {
  initWidget (binder.createAndBindUi (this));
}
...
public void setVDraggerHeight (String height)
{
  SplitLayoutPanel p = (SplitLayoutPanel) this.getWidget ();
  int widgetCount = p.getWidgetCount ();
  for (int i = 0; i < widgetCount; i++) {
    Widget w = p.getWidget (i);
    if (w.getStyleName ().equals ("gwt-SplitLayoutPanel-VDragger")) {
      w.setHeight (height);
    }
  }
}

Issue 4620: Hardcoded styling in SplitLayoutPanel

This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to Google GWT SplitLayoutPanel: How to style the Splitters

  1. Marc says:

    Thanks for the post. Probably saved me a couple of hours.

  2. Jonas says:

    You can also archive this by using CSS, but it is still a “hack”.
    .gwt-SplitLayoutPanel-VDragger{width: 2px !important;}

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">