United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6668281 NullPointerException in DefaultTableCellHeaderRenderer.getColumnSortOrder()
JDK-6668281 : NullPointerException in DefaultTableCellHeaderRenderer.getColumnSortOrder()

Details
Type:
Bug
Submit Date:
2008-02-27
Status:
Closed
Updated Date:
2011-03-07
Project Name:
JDK
Resolved Date:
2011-03-07
Component:
client-libs
OS:
windows_vista,windows_xp
Sub-Component:
javax.swing
CPU:
x86
Priority:
P2
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports
Backport:
Relates:
Relates:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.6.0_04"
Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Win32 Vista Business

A DESCRIPTION OF THE PROBLEM :
NullpointerException when trying this:

        JTableHeader header = new JTableHeader();
        TableCellRenderer headerRenderer = header.getDefaultRenderer();
        JTable table = new JTable();
//        table.setAutoCreateRowSorter(true);
        headerRenderer.getTableCellRendererComponent(table, "test", false, true, -1, 0);


uncommenting the setAutoCreateRowSorter line does not help.
Trying to set an own RowSorter does not help either.

This worked fine in 1.6.0_03.


ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NullPointerException
	at sun.swing.table.DefaultTableCellHeaderRenderer.getColumnSortOrder(Unknown Source)
	at com.sun.java.swing.plaf.windows.WindowsTableHeaderUI$XPDefaultRenderer.getTableCellRendererComponent(Unknown Source)

REPRODUCIBILITY :
This bug can be reproduced always.

Release Regression From : 6u3
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

                                    

Comments
EVALUATION

I verified this bug - it is not reproducible on 6u3
and started to appear on 6u4

it is specific to Vista

The test case:

import javax.swing.*;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;

public class bug6668281 {

    private static void createGui() {

        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            e.printStackTrace();
        }
        JTableHeader header = new JTableHeader();
        TableCellRenderer headerRenderer = header.getDefaultRenderer();
        JTable table = new JTable();
//        table.setAutoCreateRowSorter(true);
        headerRenderer.getTableCellRendererComponent(table, "test", false, true, -1, 0);
        System.out.println("end...");
    }

    public static void main(String[] args) throws Exception {
        bug6668281.createGui();
    }
}
                                     
2008-02-28
EVALUATION

This bug is a regression introduced by the fix for 6434444 [Vista: JTable differs with native table in vista laf.]

WindowsTableHeaderUI.java
109:                    getColumnSortOrder(header.getTable(), column);

This does not work in case header is not connected to a table. The code needs to be changed to:
109:                    getColumnSortOrder(table, column);
                                     
2008-02-28



Hardware and Software, Engineered to Work Together