两张SWT表争抢space
Two SWT tables fighting to grab space
我有两个 SWT table 包裹在一个 Group
中,它有一个 ScrolledComposite
来防止浏览器滚动条(而只是滚动 table)。
table_sizing_toolInfo = new Table(grpCapacityReport, SWT.BORDER);
table_sizing_toolInfo.setData( RWT.FIXED_COLUMNS, Integer.valueOf(6));
table_sizing_toolInfo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
两个 table 都有 GridData
,它抓住了多余的垂直 space。
在没有数据的情况下进行渲染时,table 会按预期工作(两者都有过多的抓取,因此它们会拆分视图 space)。
将数据填充到 table 后,它 仍会按预期显示 ,直到切换选项卡(强制重绘)。
table_sizing_dgrInfo.setRedraw(false);
table_sizing_toolInfo.setRedraw(false);
table_sizing_dgrInfo.removeAll();
table_sizing_toolInfo.removeAll();
while (table_sizing_dgrInfo.getColumnCount() > 6 ) {
table_sizing_dgrInfo.getColumns()[6].dispose();
}
while (table_sizing_toolInfo.getColumnCount() > 6 ) {
table_sizing_toolInfo.getColumns()[6].dispose();
}
renderSizingTableDynamic(scenarioMap.get(combo_sizing_ScenarioID.getText()));
table_sizing_toolInfo.setRedraw(true);
table_sizing_dgrInfo.setRedraw(true);
底部 table 比顶部 table 包含更多数据,并且随着添加更多的行,底部 table 吞没了顶部 table 的 space 直到只有一个像素高。
ScrolledComposite
不太可能满足您的需求。如果您希望两个 table 具有相同的高度,那么您应该使用这样的 Rowlayout
:
parent.setLayout( new RowLayout( SWT.VERTICAL ) );
Table topTable = new Table( parent, ... );
Table bottomTable = new Table( parent, ... );
您也可以使用 SashForm
作为两个 table 的父级。因此,让用户拖动分隔 table 的窗扇并决定每个 table 应该占用多少高度。
有关详细信息,文章 Understanding SWT Layouts 提供了对 SWT 标准布局的深入讨论。您可以安全地忽略弃用警告,那里讨论的概念仍然有效。
我有两个 SWT table 包裹在一个 Group
中,它有一个 ScrolledComposite
来防止浏览器滚动条(而只是滚动 table)。
table_sizing_toolInfo = new Table(grpCapacityReport, SWT.BORDER);
table_sizing_toolInfo.setData( RWT.FIXED_COLUMNS, Integer.valueOf(6));
table_sizing_toolInfo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
两个 table 都有 GridData
,它抓住了多余的垂直 space。
在没有数据的情况下进行渲染时,table 会按预期工作(两者都有过多的抓取,因此它们会拆分视图 space)。 将数据填充到 table 后,它 仍会按预期显示 ,直到切换选项卡(强制重绘)。
table_sizing_dgrInfo.setRedraw(false);
table_sizing_toolInfo.setRedraw(false);
table_sizing_dgrInfo.removeAll();
table_sizing_toolInfo.removeAll();
while (table_sizing_dgrInfo.getColumnCount() > 6 ) {
table_sizing_dgrInfo.getColumns()[6].dispose();
}
while (table_sizing_toolInfo.getColumnCount() > 6 ) {
table_sizing_toolInfo.getColumns()[6].dispose();
}
renderSizingTableDynamic(scenarioMap.get(combo_sizing_ScenarioID.getText()));
table_sizing_toolInfo.setRedraw(true);
table_sizing_dgrInfo.setRedraw(true);
底部 table 比顶部 table 包含更多数据,并且随着添加更多的行,底部 table 吞没了顶部 table 的 space 直到只有一个像素高。
ScrolledComposite
不太可能满足您的需求。如果您希望两个 table 具有相同的高度,那么您应该使用这样的 Rowlayout
:
parent.setLayout( new RowLayout( SWT.VERTICAL ) );
Table topTable = new Table( parent, ... );
Table bottomTable = new Table( parent, ... );
您也可以使用 SashForm
作为两个 table 的父级。因此,让用户拖动分隔 table 的窗扇并决定每个 table 应该占用多少高度。
有关详细信息,文章 Understanding SWT Layouts 提供了对 SWT 标准布局的深入讨论。您可以安全地忽略弃用警告,那里讨论的概念仍然有效。