Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6523638

NPE in BasicTableHeaderUI it incorrectly assumes presence of JTable

    Details

    • Subcomponent:
    • Introduced In Build:
      b26
    • Introduced In Version:
    • Resolved In Build:
      b10
    • CPU:
      x86
    • OS:
      windows_xp
    • Verification:
      Verified

      Backports

        Description

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

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft windows XP [Version 5.1.2600]

        A DESCRIPTION OF THE PROBLEM :
        The new row sorting mechanism for JTable in java 1.6 added code to BasicTableHeaderUI$MouseInputHandler.mouseClicked that assumes the JTableHeader has a link to an JTable.

        I have a special case where a table header is rendered without an associated JTable (permitted by the JTableHeader API). Clicking on the table header produces the following exception.

        This doesn't happen in Java 1.5

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Add a table header with no associated JTable to a visible UI and click on the table header.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        nothing
        ACTUAL -
        NullPointerException

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at javax.swing.plaf.basic.BasicTableHeaderUI$MouseInputHandler.mouseClicked(BasicTableHeaderUI.java:87)
        at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:253)
        at java.awt.Component.processMouseEvent(Component.java:6041)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
        at java.awt.Component.processEvent(Component.java:5803)
        at java.awt.Container.processEvent(Container.java:2058)
        at java.awt.Component.dispatchEventImpl(Component.java:4410)
        at java.awt.Container.dispatchEventImpl(Container.java:2116)
        at java.awt.Component.dispatchEvent(Component.java:4240)


        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
            this.getContentPane().setLayout( new BorderLayout() );
            this.setSize( new Dimension(400, 300) );
            
            JTableHeader th = new JTableHeader();
            DefaultTableColumnModel dtcm = new DefaultTableColumnModel();
            dtcm.addColumn(new TableColumn(0, 100));
            th.setColumnModel(dtcm);
            th.setPreferredSize(new Dimension(100, 20));
            this.getContentPane().add(th);4240)

        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Add an unused JTable to the JTableHeader with:
        jtableHeader.setJTable(new JTable);

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  shickeysunw Shannon Hickey (Inactive)
                  Reporter:
                  ryeung Roger Yeung (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: