From 3dbf7b1ed255abd972293521aa906c05faabf6e7 Mon Sep 17 00:00:00 2001 From: adam-m Date: Tue, 12 Feb 2013 15:13:40 -0500 Subject: [PATCH] handle rare case when graphics object is null --- .../corecomponents/DataResultViewerTable.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerTable.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerTable.java index 6de1676594..aeae00b783 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerTable.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultViewerTable.java @@ -304,18 +304,19 @@ public class DataResultViewerTable extends AbstractDataResultViewer { if (content != null) { // get the fontmetrics final Graphics graphics = ov.getGraphics(); - final FontMetrics metrics = graphics.getFontMetrics(); + if (graphics != null) { + final FontMetrics metrics = graphics.getFontMetrics(); - // for the "Name" column - int nodeColWidth = Math.min(getMaxColumnWidth(0, metrics, margin, 40, firstColumnLabel, content), 250); // Note: 40 is the width of the icon + node lines. Change this value if those values change! - ov.getOutline().getColumnModel().getColumn(0).setPreferredWidth(nodeColWidth); + // for the "Name" column + int nodeColWidth = Math.min(getMaxColumnWidth(0, metrics, margin, 40, firstColumnLabel, content), 250); // Note: 40 is the width of the icon + node lines. Change this value if those values change! + ov.getOutline().getColumnModel().getColumn(0).setPreferredWidth(nodeColWidth); - // get the max for each other column - for (int colIndex = startColumn; colIndex <= totalColumns; colIndex++) { - int colWidth = Math.min(getMaxColumnWidth(colIndex, metrics, margin, 8, props, content), 350); - ov.getOutline().getColumnModel().getColumn(colIndex).setPreferredWidth(colWidth); + // get the max for each other column + for (int colIndex = startColumn; colIndex <= totalColumns; colIndex++) { + int colWidth = Math.min(getMaxColumnWidth(colIndex, metrics, margin, 8, props, content), 350); + ov.getOutline().getColumnModel().getColumn(colIndex).setPreferredWidth(colWidth); + } } - } // if there's no content just auto resize all columns