Subject: NullReferenceException setting column width in grid |
Author: Pete Davis |
Date: Sun, 25 January 2015 15:57 |
First, I'm pretty new to Eclipse and Nebula.
I just figured out the solution to my problem, but I'd like to understand why this should be happening, because to me, this seems like a bug:
I created a grid as follows:
@Override
protected Control createContents(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
Grid grid = new Grid(container, SWT.BORDER);
grid.setHeaderVisible(true);
grid.setBounds(10, 10, 414, 169);
GridColumn col1 = new GridColumn(grid, SWT.NONE);
col1.setText("Col1");
col1.setWidth(100);
GridColumn col2 = new GridColumn(grid, SWT.NONE);
col2.setText("Col2");
col2.setWidth(100);
return container;
}
This throws a NullReferenceException in the setWidth() call in Grid.handlePacked() because getHorizontalBar() returns null.
Of course the fix was to create my grid with scrollbars and looking over the examples, it looks like they all do that. But my question is, why? If the grid can't function properly without the SWT.V_SCROLLBAR | SWT.H_SCROLLBAR stuff being passed into the constructor, why aren't those styles just set by default?
|
[ Reply ][ Quote ][ View Topic/Message ][ Unsubscribe from this forum ]
|