JDK-6884066 : JTableHeader listens mouse in disabled state and doesn't work when not attached to a table
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6,6u14,7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,windows_xp,windows_vista
  • CPU: generic,x86
  • Submitted: 2009-09-21
  • Updated: 2011-01-19
  • Resolved: 2010-01-13
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
6u18 b03Fixed 7Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
This is an umbrella CR for two problems with JTableHeader

1) JTableHeader reacts to the mouse when disabled

public class TableHeaderDisabled {

    private JComponent createContent() {
        JTable table = new JTable(20, 5);
        table.setAutoCreateRowSorter(true);
        table.setEnabled(false);
        table.getTableHeader().setEnabled(false);
        JComponent content = new JScrollPane(table);
        return content;
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JFrame frame = new JFrame("");
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.add(new TableHeaderDisabled().createContent());
                frame.setLocationRelativeTo(null);
                frame.pack();
                frame.setVisible(true);
            }
        });
    }

} 

2) JTableHeader doesn't allow to drag a column to a new place when it is not attached to a JTable, try to drag a column to a new place with the following test case:
(not that the dragged column returns to its initial place!)

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

public class TableHeaderStandAlone {

    private static void createGui() {
        final JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        // just to quickly grab a column model
        JTable table = new JTable(10, 5);
        JTableHeader header = new JTableHeader(table.getColumnModel());
        frame.add(header);
        
        frame.setSize(200, 200);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

    public static void main(String[] args) throws Exception {
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                TableHeaderStandAlone.createGui();
            }
        });
    }
}

Comments
EVALUATION should be fixed
21-09-2009