use of javax.swing.table.DefaultTableCellRenderer in project jmeter by apache.
the class UserParametersGui method getMaximalRequiredColumnWidth.
/**
* Compute max width between width of the largest column at columnIndex and headerWidth
* @param columnIndex Column index
* @param headerWidth Header width based on Font
*/
private int getMaximalRequiredColumnWidth(int columnIndex, int headerWidth) {
int maxWidth = headerWidth;
TableColumn column = paramTable.getColumnModel().getColumn(columnIndex);
TableCellRenderer cellRenderer = column.getCellRenderer();
if (cellRenderer == null) {
cellRenderer = new DefaultTableCellRenderer();
}
for (int row = 0; row < paramTable.getModel().getRowCount(); row++) {
Component rendererComponent = cellRenderer.getTableCellRendererComponent(paramTable, paramTable.getModel().getValueAt(row, columnIndex), false, false, row, columnIndex);
double valueWidth = rendererComponent.getPreferredSize().getWidth();
maxWidth = (int) Math.max(maxWidth, valueWidth);
}
return maxWidth;
}
use of javax.swing.table.DefaultTableCellRenderer in project processdash by dtuma.
the class TeamMemberListTable method prepareRenderer.
@Override
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
Component result = super.prepareRenderer(renderer, row, column);
if (result instanceof DefaultTableCellRenderer) {
if (row == getSelectedRow() && column == getSelectedColumn())
;
else if (isCellEditable(row, column))
result.setBackground(getBackground());
else
result.setBackground(unmodifiableCellBackground);
}
return result;
}
Aggregations