Home > OutlineView > Recipe 8: Hide node column in OutlineView

Recipe 8: Hide node column in OutlineView

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);
Advertisements
Categories: OutlineView
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: