// all columns will be same size while the NatTable itself will have
// 100%
final DataLayer n1DataLayer = new DataLayer(dataProvider);
n1DataLayer.setColumnPercentageSizing(true);
n1DataLayer.setRowPercentageSizing(true);
ViewportLayer layer = new ViewportLayer(new SelectionLayer(n1DataLayer));
layer.setRegionName(GridRegion.BODY);
final NatTable n1 = new NatTable(simplePanel, layer);
GridDataFactory.fillDefaults().grab(true, true).applyTo(n1);
// example for fixed percentage sizing
// ensure that the sum of column sizes is not greater than 100
final DataLayer n2DataLayer = new DataLayer(dataProvider);
n2DataLayer.setColumnWidthPercentageByPosition(0, 25);
n2DataLayer.setColumnWidthPercentageByPosition(1, 25);
n2DataLayer.setColumnWidthPercentageByPosition(2, 50);
layer = new ViewportLayer(new SelectionLayer(n2DataLayer));
layer.setRegionName(GridRegion.BODY);
final NatTable n2 = new NatTable(simplePanel, layer);
GridDataFactory.fillDefaults().grab(true, true).applyTo(n2);
// example for mixed percentage sizing
// configure not every column with the exact percentage value, this way
// the columns for which
// no exact values are set will use the remaining space
final DataLayer n3DataLayer = new DataLayer(dataProvider);
n3DataLayer.setColumnPercentageSizing(true);
n3DataLayer.setColumnWidthPercentageByPosition(0, 40);
n3DataLayer.setColumnWidthPercentageByPosition(2, 40);
layer = new ViewportLayer(new SelectionLayer(n3DataLayer));
layer.setRegionName(GridRegion.BODY);
final NatTable n3 = new NatTable(simplePanel, layer);
GridDataFactory.fillDefaults().grab(true, true).applyTo(n3);
// example for mixed fixed/percentage sizing
// configure not every column with the exact percentage value, this way
// the columns for which
// no exact values are set will use the remaining space
final DataLayer mixDataLayer = new DataLayer(dataProvider);
mixDataLayer.setColumnPercentageSizing(true);
mixDataLayer.setColumnPercentageSizing(0, false);
mixDataLayer.setColumnPercentageSizing(1, false);
mixDataLayer.setColumnWidthByPosition(0, 100);
mixDataLayer.setColumnWidthByPosition(1, 100);
layer = new ViewportLayer(new SelectionLayer(mixDataLayer));
layer.setRegionName(GridRegion.BODY);
final NatTable mix = new NatTable(simplePanel, layer);
GridDataFactory.fillDefaults().grab(true, true).applyTo(mix);
// example for percentage calculation with default sizing in a grid
// all columns will be same size while the NatTable itself will have