KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > swingwtx > swing > table > JTableHeader


1 /*
2    SwingWT
3    Copyright(c)2003-2004, R. Rawson-Tetley
4
5    For more information on distributing and using this program, please
6    see the accompanying "COPYING" file.
7
8    Contact me by electronic mail: bobintetley@users.sourceforge.net
9
10    $Log: JTableHeader.java,v $
11    Revision 1.5 2004/04/27 13:44:39 bobintetley
12    Fix to build from SwingWT source in makefile and fixes to JTableHeader to allow it
13
14    Revision 1.4 2004/04/16 10:19:07 dannaab
15    Misc bug fixes, InputMap implementation, preliminary undo support
16
17    Revision 1.3 2004/01/26 08:11:14 bobintetley
18    Many bugfixes and addition of SwingSet
19
20    Revision 1.2 2003/12/17 10:57:35 bobintetley
21    JTableHeader implementation plus Table event/model fixes
22
23    Revision 1.1 2003/12/15 16:40:05 bobintetley
24    Core methods + skeleton JTableHeader/JScrollBar support
25
26 */

27
28 package swingwtx.swing.table;
29
30 import swingwt.awt.Point;
31 import swingwtx.swing.JTable;
32
33 public class JTableHeader extends swingwtx.swing.JComponent {
34
35     protected JTable table = null;
36     protected TableColumn resizingColumn = null;
37
38     public JTableHeader(JTable table) { this.table = table; }
39     
40     public TableColumnModel getColumnModel() { return table.getColumnModel(); }
41     public void setColumnModel(TableColumnModel t) { table.setColumnModel(t); }
42     public boolean isReorderingAllowed() { return false; }
43     public void setReorderingAllowed(boolean b) {}
44     public JTable getTable() { return table; }
45     public int columnAtPoint(Point point) {
46         int x = point.x;
47         if (!getComponentOrientation().isLeftToRight()) {
48             if (table != null && table.getAutoResizeMode() != swingwtx.swing.JTable.AUTO_RESIZE_OFF) {
49                 x = table.getWidth() - x;
50             }
51             else x = super.getWidth() - x;
52         }
53
54         return getColumnModel().getColumnIndexAtX(x);
55     }
56     public TableColumn getResizingColumn() { return resizingColumn; }
57     public void setResizingColumn(TableColumn resizingColumn) { this.resizingColumn = resizingColumn; }
58 }
59
Popular Tags