01: package abbot.tester;
02:
03: import java.awt.Component;
04: import java.awt.Point;
05: import javax.swing.table.JTableHeader;
06:
07: /** Provide table header location support, mostly. */
08:
09: public class JTableHeaderTester extends JComponentTester {
10:
11: /** Parse the String representation of a JTableHeaderLocation into the
12: actual JTableHeaderLocation object.
13: */
14: public ComponentLocation parseLocation(String encoded) {
15: return new JTableHeaderLocation().parse(encoded);
16: }
17:
18: /** Return (in order of preference) the location corresponding to column
19: name (value), column index, or coordinate.
20: */
21: public ComponentLocation getLocation(Component c, Point p) {
22: JTableHeader header = (JTableHeader) c;
23: int col = header.columnAtPoint(p);
24: if (col != -1) {
25: String value = header.getTable().getModel().getColumnName(
26: col);
27: if (value != null) {
28: return new JTableHeaderLocation(value);
29: }
30: return new JTableHeaderLocation(col);
31: }
32: return new JTableHeaderLocation(p);
33: }
34: }
|