Hello Team,
I have a requirement where I combine 3 tables to show it as a single table. Which means Table 1 have a header and the other two tables doesnt have headers. Now the issue is, when I click on the header of the first table, the same column has to selected on all three tables.
I added my own implementation of mouseListener to my header. Here is the code snippet which is there within mouseClicked()
tableList is the ArrayList that contains list of tables. Table1 will be always there in the zeroth position of the list, which means tableList(0) will always have the table header.
public void mouseClicked(MouseEvent e)
{
for ( JTable table : tableList ) {
JTableHeader header = tableList.get(0).getTableHeader();
int column = header.columnAtPoint(e.getPoint());
int count = table.getRowCount();
if (count != 0) {
table.clearSelection();
table.setColumnSelectionInterval( column, column);
table.setRowSelectionInterval(0, count - 1);
}
}
}
I get the control within this function when I click the header, and also I do get the column position where I click. But I am unable to select the columns from different table.
Any help is highly appreciated.
Thanks
Gokul