如何在GWT CellBrowser上设置第一列宽度

如何在GWT CellBrowser上设置第一列宽度,gwt,cellbrowser,Gwt,Cellbrowser,有一个错误阻止设置CellBrowser小部件的第一列宽度。这里还介绍了一种变通方法 显然它是有效的,但有人能解释一下如何对CellBrowser进行子类化以使其有效吗?请给我看一些代码 CellBrowser cellBrowser = new CellBrowser(model, null) { // HACK: workaround for setDefaultColumnWidth not setting the width of the first colu

有一个错误阻止设置CellBrowser小部件的第一列宽度。这里还介绍了一种变通方法

显然它是有效的,但有人能解释一下如何对CellBrowser进行子类化以使其有效吗?请给我看一些代码

    CellBrowser cellBrowser = new CellBrowser(model, null) {

        // HACK: workaround for setDefaultColumnWidth not setting the width of the first column!
        // SEE: https://groups.google.com/forum/?pli=1#!topic/google-web-toolkit/T8Ob...

        public void setDefaultColumnWidth(int width) {
            super.setDefaultColumnWidth(width);
             SplitLayoutPanel splitPanel =  (SplitLayoutPanel) getWidget();
             splitPanel.setWidgetSize(splitPanel.getWidget(0), width);
        }
    };

    cellBrowser.setDefaultColumnWidth(300);   
  • 从问题中链接到的线程:
如果您想要一个具有此修复程序的可重用类(这可能是一个好主意),将此匿名子类转换为常规子类非常简单:

    public class FixedCellBrowser<T> extends CellBrowser<T> {

        public FixedCellBrowser(TreeViewModel model, T root) {
            super(model, root);
        }

        public void setDefaultColumnWidth(int width) {
            super.setDefaultColumnWidth(width);
             SplitLayoutPanel splitPanel =  (SplitLayoutPanel) getWidget();
             splitPanel.setWidgetSize(splitPanel.getWidget(0), width);
        }
    }
公共类FixedCellBrowser扩展了CellBrowser{
公共FixedCellBrowser(TreeView模型,T根){
超级(模型,根);
}
公共void setDefaultColumnWidth(int-width){
super.setDefaultColumnWidth(宽度);
SplitLayoutPanel splitPanel=(SplitLayoutPanel)getWidget();
splitPanel.setWidgetSize(splitPanel.getWidget(0),宽度);
}
}
(注意:我没有尝试编译此代码。)