-
Bug
-
Resolution: Fixed
-
P2
-
6, 6u14, 7
-
b03
-
generic, x86
-
generic, windows_xp, windows_vista
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2193657 | 7 | Alexander Potochkin | P2 | Closed | Fixed | b97 |
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();
}
});
}
}
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();
}
});
}
}
- backported by
-
JDK-2193657 JTableHeader listens mouse in disabled state and doesn't work when not attached to a table
- Closed
- duplicates
-
JDK-6550602 Disabled JTableHeader allows sorting.
- Closed
-
JDK-6882488 JTableHeader: must not react to mouse if disabled
- Closed
- relates to
-
JDK-6889007 No resize cursor during hovering mouse over JTable
- Closed
-
JDK-6777378 NullPointerException in XPDefaultRenderer.paint()
- Closed