I had a problem setting the width of a JTable column.
The code below works fine:
TableColumn a =shipsAndOwnHitsTable.getColumnModel().getColumn(0); a.setPreferredWidth(800);
It changes the width of the first column.
However, when posting for some time or in a for loop, nothing happens:
int index = 0; while (index < columnNum){ TableColumn a =shipsAndOwnHitsTable.getColumnModel().getColumn(index); a.setPreferredWidth(800); index+=1; }
This code does not work, nothing happens with column sizes, can someone explain why? If not, someone will tell me how to set the width of the row and column the same way, i.e. I want all the cells in my table to be square, regardless of the size of the table (rows and columns).?
thanks
source share