is it possible to add an offset to the text for the cells without the expand button in it, so that the text in all cells of the same column start at the same position?
Right now if there are cells with this expand button and cells without, the text is not in one line (because of the small "+" icon).
I tried to add spaces to the text of the cell with no icon. But i encountered two problems.
First, it seems that my renderer does not effect the row header table. The table did not change.
Second problem is, how can i check if a specific cell as this expand button?
- Code: Select all
final TableCellRenderer renderer = CellRendererManager.getRenderer(String.class);
CellRendererManager.registerRenderer(String.class, new TableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
Component comp = renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
ContextSensitiveCellRenderer scr = (ContextSensitiveCellRenderer)comp;
scr.setText(" " + scr.getText());
return scr;
}
});
Can you show me how to do this please?