-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCTable.java
More file actions
44 lines (40 loc) · 1.33 KB
/
CTable.java
File metadata and controls
44 lines (40 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication2;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
public class CTable extends JTable {
public CMap map;
public CTable(CMap cmp, TableModel tbl) {
super(tbl);
map = cmp;
setUI(new CTUI());
}
public Rectangle getCellRect(int row, int column, boolean includeSpacing) {
// required because getCellRect is used in JTable constructor
if (map == null)
return super.getCellRect(row, column, includeSpacing);
// add widths of all spanned logical cells
int sk = map.visibleCell(row, column);
//Rectangle r1 = super.getCellRect(row, sk, includeSpacing);
Rectangle r1 = super.getCellRect( sk, column, includeSpacing);
if (map.span( sk, column ) != 1)
for (int i = 1; i < map.span( sk, column ); i++) {
//r1.width += getColumnModel().getColumn(sk + i).getWidth();
r1.height += this.getRowHeight( sk + i );
}
return r1;
}
public int rowAtPoint(Point p) {
int x = super.columnAtPoint(p);
// -1 is returned by columnAtPoint if the point is not in the table
if (x < 0)
return x;
int y = super.rowAtPoint(p);
return map.visibleCell(y, x);
}
}