@Override
public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
boolean consumed = super.mouseClick(component, button, x, y, count);
if (button == Mouse.Button.LEFT) {
TableViewHeader tableViewHeader = (TableViewHeader)getComponent();
TableView tableView = tableViewHeader.getTableView();
if (resizeHeaderIndex != -1) {
TableView.Column column = tableView.getColumns().get(resizeHeaderIndex);
if (count == 2
&& !column.isRelative()
&& column.getWidth() != -1) {
// Size the column to fit its contents
int columnWidth = 0;
TableView.CellRenderer cellRenderer = column.getCellRenderer();
List<?> tableData = tableView.getTableData();
int rowIndex = 0;
for (Object rowData : tableData) {
cellRenderer.render(rowData, rowIndex++, resizeHeaderIndex, tableView,
column.getName(), false, false, false);
columnWidth = Math.max(cellRenderer.getPreferredWidth(-1), columnWidth);
}
column.setWidth(columnWidth);
}
} else if (pressedHeaderIndex != -1) {
// Press the header
tableViewHeader.pressHeader(pressedHeaderIndex);
// Update the sort
TableViewHeader.SortMode sortMode = tableViewHeader.getSortMode();
if (sortMode != TableViewHeader.SortMode.NONE) {
TableView.Column column = tableView.getColumns().get(pressedHeaderIndex);
String columnName = column.getName();