In your code, you must have a reference to your JTable
You can use something like this.
yourTable.getColumnModel().getColumn(0).setPreferredWidth(10);
yourTable.getColumnModel().getColumn(1).setPreferredWidth(20);
Question
I am populating the jTable from DB but puts gap for each cell up to beginning of the next column shown in picture below , how to fix that ? I will be happy you can comment on this thanks.
La solution
In your code, you must have a reference to your JTable
You can use something like this.
yourTable.getColumnModel().getColumn(0).setPreferredWidth(10);
yourTable.getColumnModel().getColumn(1).setPreferredWidth(20);