public boolean isColumnVisible(int columnIndex) {
int x = 0;
int len = table.getColumnCount();
int lastwidth = 0;
for (int i = 0; i < len; i++) {
if (i <= columnIndex) {
TableColumn tcolumn = table.getColumn(i);
lastwidth = tcolumn.getWidth();
x = x + tcolumn.getWidth();
}
}
Rectangle rectangle = table.getClientArea();
ScrollBar hb = table.getHorizontalBar();
ScrollBar vb = table.getVerticalBar();
if (x <= (hb.getSelection() + rectangle.width) && (x >= hb.getSelection()) && ((x - lastwidth) >= hb.getSelection())) {
return true;
}
return false;
}
public boolean isRowVisible(int row) {
Rectangle rectangle = table.getClientArea();
TableItem startItem = table.getItem(new Point(rectangle.x, rectangle.y + table.getHeaderHeight()));
TableItem endItem = table.getItem(new Point(rectangle.x, rectangle.height - 5));
if (endItem == null) {
endItem = table.getItem(table.getItemCount() - 1);
}
if (startItem == null || endItem == null)
return false;
int startrow = table.indexOf(startItem);
int endrow = table.indexOf(endItem);
if (startrow <= row && endrow >= row) {
return true;
}
return false;
}