mabe02 / lanterna

Java library for creating text-based GUIs
GNU Lesser General Public License v3.0
2.24k stars 243 forks source link

DefaultTableRenderer not handling zero rows properly when calculating preferred size #500

Closed amacgaffey closed 3 years ago

amacgaffey commented 4 years ago

Line 242 // If there are no rows, base the column sizes off of the column labels if( tableModel.getColumnCount() == 0) { ... }

Should be:

// If there are no rows, base the column sizes off of the column labels if( tableModel.getRowCount() == 0) {

mabe02 commented 4 years ago

Sorry, which branch/tag are you looking at? Here's what I see in the latest release/3.1 for line 242:

        // If there are no rows, base the column sizes off of the column labels
        if(rows.size() == 0) {
            for(int columnIndex = 0; columnIndex < columnHeaders.size(); columnIndex++) {
                int columnSize = tableHeaderRenderer.getPreferredSize(table, columnHeaders.get(columnIndex), columnIndex).getColumns();
                if(preferredColumnSizes.size() == columnIndex) {
                    preferredColumnSizes.add(columnSize);
                }
                else {
                    if(preferredColumnSizes.get(columnIndex) < columnSize) {
                        preferredColumnSizes.set(columnIndex, columnSize);
                    }
                }
            }
        }
amacgaffey commented 3 years ago

You are correct. A non-issue. Thanks for the prompt response.