Archive

Archive for April, 2013

Recipe 8: Hide node column in OutlineView

April 14, 2013 Leave a comment

Problem

The OutlineView is a combined tree/table structure. As a consequence, when using it to display tabular data, the node column is displayed as the first column of the table in addition to the data columns. How can I remove it?

Solution

In older (< 7.0) versions of NetBeans, it was recommended to use this trick:

outlineView.getOutline().setRootVisible(false);
outlineView.getOutline().getColumnModel().removeColumn(outlineView.getOutline().getColumnModel().getColumn(0));

However, it is not a good idea to remove this column because NetBeans is using it. The recommended way, that works in 7.0 (there seems to be a bug in previous versions), is:

Outline outline = outlineView.getOutline();
outline.setRootVisible(false);
TableColumnModel columnModel = outline.getColumnModel();
ETableColumn column = (ETableColumn) columnModel.getColumn(0);
((ETableColumnModel) columnModel).setColumnHidden(column, true);
Categories: OutlineView