Question:
I am looking for a way to change the width of the columns of my Jtable
. For the design I use a graphic tool, but I can't find the corresponding option.
Answer:
This is the construction to do it from the code: JTable.getColumnModel().getColumn(0).setPreferredWidth(100);
If you have a table of x, you have to define all of them as JTable needs to have the sizes of all to function.
TableColumnModel columnModel = table.getColumnModel();
columnModel.getColumn(0).setPreferredWidth(50);
columnModel.getColumn(1).setPreferredWidth(150);
columnModel.getColumn(2).setPreferredWidth(200);
columnModel.getColumn(3).setPreferredWidth(250);