01: package org.gui4j.core.swing;
02:
03: // File: GroupableTableHeader.java
04: //
05: /*
06: * (swing1.1beta3)
07: *
08: */
09:
10: import java.util.Enumeration;
11: import java.util.Vector;
12:
13: import javax.swing.table.JTableHeader;
14: import javax.swing.table.TableColumn;
15: import javax.swing.table.TableColumnModel;
16:
17: /**
18: * GroupableTableHeader
19: *
20: * @version 1.0 10/20/98
21: * @author Nobuo Tamemasa
22: */
23:
24: public class GroupableTableHeader extends JTableHeader {
25: protected Vector columnGroups = null;
26:
27: public GroupableTableHeader(TableColumnModel model) {
28: super (model);
29: setUI(new GroupableTableHeaderUI());
30: setReorderingAllowed(false);
31: }
32:
33: public void setReorderingAllowed(boolean b) {
34: reorderingAllowed = false;
35: }
36:
37: public void addColumnGroup(ColumnGroup g) {
38: if (columnGroups == null) {
39: columnGroups = new Vector();
40: }
41: columnGroups.addElement(g);
42: }
43:
44: public Enumeration getColumnGroups(TableColumn col) {
45: if (columnGroups == null)
46: return null;
47: Enumeration en = columnGroups.elements();
48: while (en.hasMoreElements()) {
49: ColumnGroup cGroup = (ColumnGroup) en.nextElement();
50: Vector v_ret = cGroup.getColumnGroups(col, new Vector());
51: if (v_ret != null) {
52: return v_ret.elements();
53: }
54: }
55: return null;
56: }
57:
58: public void setColumnMargin() {
59: if (columnGroups == null)
60: return;
61: int columnMargin = getColumnModel().getColumnMargin();
62: Enumeration en = columnGroups.elements();
63: while (en.hasMoreElements()) {
64: ColumnGroup cGroup = (ColumnGroup) en.nextElement();
65: cGroup.setColumnMargin(columnMargin);
66: }
67: }
68:
69: }
|