}
);
// calculate row preferredWidth
- int windowMargin = this.getWidth() - gLogTable.getWidth();
- int tableMargin = gLogTable.getWidth() - gLogTable.getColumnModel().getTotalColumnWidth();
+ if (currentLogTableRowWidth == 0)
+ currentLogTableRowWidth = gLogTable.getWidth();
+ int windowMargin = this.getWidth() - gLogScroller.getWidth();
int lastRow = gLogTable.getRowCount() - 1;
int spacing = gLogTable.getIntercellSpacing().width;
int rowWidth = 0;
for (int column = 0; column < gLogTable.getColumnCount(); column++) {
int preferredWidth = gLogTable.prepareRenderer(gLogTable.getCellRenderer(lastRow, column), lastRow, column).getPreferredSize().width;
- int actualWidth = gLogTable.prepareRenderer(gLogTable.getCellRenderer(lastRow, column), lastRow, column).getSize().width;
- int minimumWidth = java.lang.Math.max(actualWidth, preferredWidth);
- if (minimumWidth > currentLogTableRowWidths[column])
- currentLogTableRowWidths[column] = minimumWidth + 8; // add hard-coded margin to ensure column is wider than rendered contents
+ if (preferredWidth > currentLogTableRowWidths[column])
+ currentLogTableRowWidths[column] = preferredWidth + 8; // add hard-coded margin to ensure column is wider than rendered contents
rowWidth += spacing + currentLogTableRowWidths[column];
+ System.err.println(MessageFormat.format("Column={0} preferred={1} rowWidth={2}", column, preferredWidth, rowWidth));
gLogTable.getColumnModel().getColumn(column).setPreferredWidth(currentLogTableRowWidths[column]);
}
+ System.err.flush();
if (rowWidth > currentLogTableRowWidth) {
- java.awt.Dimension windowSize = new java.awt.Dimension(windowMargin + tableMargin + rowWidth, this.getHeight());
+ java.awt.Dimension windowSize = new java.awt.Dimension(this.getWidth() + (rowWidth - currentLogTableRowWidth), this.getHeight());
// FIXME: isLoggable(): remove auto table column and window resize console debug messages once resizing is confirmed to work correctly
- System.err.println(MessageFormat.format("Before: window={0} margin={2} table={1} margin={3} currentRowWidth={4} newRowWidth={5}", this.getWidth(), gLogTable.getWidth(), windowMargin, tableMargin, currentLogTableRowWidth, rowWidth));
- gLogTable.validate();
+ System.err.println(MessageFormat.format("Before: window={0} margin={1} table={2} currentRowWidth={3} newRowWidth={4}", this.getWidth(), windowMargin, gLogTable.getWidth(), currentLogTableRowWidth, rowWidth));
this.setSize(windowSize);
currentLogTableRowWidth = rowWidth;
- System.err.println(MessageFormat.format(" After: window={0} margin={2} table={1} margin={3} currentRowWidth={4} newRowWidth={5}", this.getWidth(), gLogTable.getWidth(), windowMargin, tableMargin, currentLogTableRowWidth, rowWidth));
+ System.err.println(MessageFormat.format(" After: window={0} margin={1} table={2} currentRowWidth={3} newRowWidth={4}", this.getWidth(), windowMargin, gLogTable.getWidth(), currentLogTableRowWidth, rowWidth));
}
if (_autoScroll) // keep last record added in the view
gLogTable.scrollRectToVisible(gLogTable.getCellRect(lastRow, 0, true));