JDK-6668281 : NullPointerException in DefaultTableCellHeaderRenderer.getColumnSortOrder()
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp,windows_vista
  • CPU: x86
  • Submitted: 2008-02-27
  • Updated: 2011-03-07
  • Resolved: 2011-03-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u10Fixed 7 b38Fixed
Related Reports
Relates :  
Relates :  
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 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);
28-02-2008

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(); } }
28-02-2008